Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

API for Save for Web?

Status
Not open for further replies.

xtektips

Programmer
Mar 22, 2005
5
TW
I am writing a VB application that will automatically do some custom resizing of PSD files and saving them to JPEG files. However, I am not able to find an API for "Save for Web" functionality. So the resulting JPEG files from "Save as" are larger in size than "Save for Web".

My questions are:

1) Is there a API for "Save for Web" that I don't know about?

2) If not, how can I make JPEG files from "Save as" the same "quality/size" as "Save for Web"?

Thanks
 
Actually there is little difference - when saving to jpeg - between Save As and Save for Web.

The only thing that Save for Web does automacially is make sure the dpi is 72. All the other controls are the same: quality, optimize, etc. If the PS doc is already set to 72 dpi, Save for Web does not do any changing that is not done in Save As.

As long as your script tells PS to change to 72 dpi before the Save As, there will be no problem in the image size.
 
Save as" does different thing than "Save for web" beside the 72 dpi. I can manually change the photo to 72 dpi, the resulting JPEG is still different AND is much smaller (the original dpi is 300 dpi).

The reason that I need to do the programming is to figure out the height and width to resize do. It is different for each file. Also the resulting file name is different based on some rules.

In any case, here is an url for the "Save for web" scripting in Javascript,
Based on that, here is the VB version that I wrote.

strFileOut = "c:\file.jpg" 'Your file name here

Dim desc3 As New Photoshop.ActionDescriptor
Dim desc4 As New Photoshop.ActionDescriptor
Dim list1 As New Photoshop.ActionList

desc4.PutEnumerated mPhotoshop.CharIDToTypeID("Op "), _
mPhotoshop.CharIDToTypeID("SWOp"), _
mPhotoshop.CharIDToTypeID("OpSa")

desc4.PutEnumerated mPhotoshop.CharIDToTypeID("Fmt "), _
mPhotoshop.CharIDToTypeID("IRFm"), _
mPhotoshop.CharIDToTypeID("JPEG")

desc4.PutEnumerated mPhotoshop.CharIDToTypeID("Op "), _
mPhotoshop.CharIDToTypeID("SWOp"), _
mPhotoshop.CharIDToTypeID("OpSa")

desc4.PutBoolean mPhotoshop.CharIDToTypeID("Intr"), False
desc4.PutInteger mPhotoshop.CharIDToTypeID("Qlty"), iQuality * 10
desc4.PutInteger mPhotoshop.CharIDToTypeID("QChS"), 0
desc4.PutInteger mPhotoshop.CharIDToTypeID("QCUI"), 0
desc4.PutBoolean mPhotoshop.CharIDToTypeID("QChT"), False
desc4.PutBoolean mPhotoshop.CharIDToTypeID("QChV"), False
desc4.PutBoolean mPhotoshop.CharIDToTypeID("Optm"), True
desc4.PutInteger mPhotoshop.CharIDToTypeID("Pass"), 1
desc4.PutDouble mPhotoshop.CharIDToTypeID("blur"), 0#
desc4.PutBoolean mPhotoshop.CharIDToTypeID("EICC"), False
desc4.PutBoolean mPhotoshop.CharIDToTypeID("Mtt "), True
desc4.PutInteger mPhotoshop.CharIDToTypeID("MttR"), 255
desc4.PutInteger mPhotoshop.CharIDToTypeID("MttG"), 255
desc4.PutInteger mPhotoshop.CharIDToTypeID("MttB"), 255
desc4.PutBoolean mPhotoshop.CharIDToTypeID("SHTM"), False
desc4.PutBoolean mPhotoshop.CharIDToTypeID("SImg"), True
desc4.PutBoolean mPhotoshop.CharIDToTypeID("SSSO"), False
desc4.PutList mPhotoshop.CharIDToTypeID("SSLt"), list1
desc4.PutBoolean mPhotoshop.CharIDToTypeID("DIDr"), False
desc4.PutPath mPhotoshop.CharIDToTypeID("In "), strFileOut

desc3.PutObject mPhotoshop.CharIDToTypeID("Usng"), _
mPhotoshop.StringIDToTypeID("SaveForWeb"), _
desc4

mPhotoshop.ExecuteAction mPhotoshop.CharIDToTypeID("Expr"), _
desc3, psDisplayNoDialogs

docRef.Close psDoNotSaveChanges
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top