I’m using Photoshop CS under OS X 10.3.9 to open hundreds of EPS files and save them as TIFFs. I want the TIFFs to be 600 dpi, grayscale. Here’s my code:
tell application "Adobe Photoshop CS"
activate
open file (((docPath as string) & outFile & ".eps") as string) showing dialogs never with options {mode:grayscale, resolution:600, use antialias:false, constrain proportions:true}
save document 1 in file (((docPath as string) & outFile & ".tif") as string) as TIFF with options {byte order:Mac OS, embed color profile:false, image compression:LZW, save alpha channels:false, save layers:false} appending lowercase extension with copying
close document 1 without saving
end tell
When I inspect the TIFFs, they’ve been saved at 72dpi. If I do this manually, opening the EPS at 600dpi, the saved TIFF is 600dpi as expected. Is this a bug in Photoshop CS? Any suggestion of an alternative method of doing this, keeping in mind that my EPS files are 7 per week in 52 weekly folders?
Do yourself a big favor - and do as much as you can with an action in photoshop - it’s just a lot easier. Then - with applescript - use do action (or do script, I can never remember) to run each image through the action.
I process thousands of images per week this way - and find it’s really the best way to do it. The only thing you need to do if you use this method - is make sure you error check before you start the action - as there is no way to use conditionals in an action so if you , for example - want to activate “path 1” - and the image doesn’t have “path 1” your script will error out. So - in that example - you check to see if path 1 exists first, BEFORE unleashing the action on it.
Chris, I’m not familiar with Applescripting Photoshop’s actions. In this particular case, the problem I seem to be having is that, unlike in the example you cited, the Applescript command to Photoshop to open the EPS file (i.e., from my Applescript file list) is itself causing the problem BEFORE the file gets into Photoshop to be affected by a Photoshop action (i.e., saved as TIFF). To recap, the EPS file is opening rasterized with 72dpi rather than 600dpi.
Perhaps, being more familiar with Photoshop actions, you know of some way I can pass filename arguments from Applescript into Photoshop, so that the list of files built in Applescript can replace, one at a time, the static value I see in the Photoshop action for file opening.
Or, perhaps you’d be willing to do a quick check on whether an Applescript can tell Photoshop to open and rasterize a vector EPS file at other than 72dpi? I wonder whether it is the EPS file’s preview that is being used by Photoshop, for instance, instead of a 600dpi rasterization.
I think you need to say open file as EPS with options:
open myFilePath as EPS with options {class:EPS open options, height:100, width:100, mode:grayscale, resolution:600, use antialias:false, constrain proportions:true}
I agree that you need to spec EPS open options. I have also noticed in Photoshop (I am in CS2 but it is probably the same in CS) that it is a little goofy about resolution. I have found that if you try to spec the resolution AND the pixel dimensions, it will default to setting the document to the pixel dimensions at 72 ppi. If you spec a measurement in inches for example, it will keep the resolution. It doesn’t look like you are specing a size so the problem may be as simple as adding the “class:EPS open options”. I think your open statement should look like this:
open file (((docPath as string) & outFile & ".eps") as string) showing dialogs never with options {class:EPS open options, mode:grayscale, resolution:600, use antialias:false, constrain proportions:true}
And lastly, for what you are doing, you might want to experiment with Photoshop actions. You can batch process and wouldn’t have to use AppleScript at all. YOu action would only be three or four steps I would imagine.
I can’t figure out how, in an action, to open just the eps files matching a certain pattern in each of 50 different folders within a master folder. Can one use repeat loops, with filename patterns, in actions?
And when I add class:EPS to the Applescript, I get this error:
This is working for me in CS1 on the part of photoshop. I am new to scripting so may be someone else can advise you on the finder part of this. Hope this helps in some way.
set tempFolderName to "Converted to TIF at 600dpi"
set inputFolder to choose folder
tell application "Finder"
set filesList to files in inputFolder
if (not (exists folder ((inputFolder as string) & tempFolderName))) then
set outputFolder to make new folder at inputFolder with properties {name:tempFolderName}
else
set outputFolder to folder ((inputFolder as string) & tempFolderName)
end if
end tell
tell application "Adobe Photoshop CS"
set display dialogs to never
close every document saving no
end tell
repeat with aFile in filesList
set fileIndex to 0
tell application "Finder"
set theFile to aFile as alias
set theFileName to name of theFile
end tell
tell application "Adobe Photoshop CS"
set background color to {class:RGB color, red:255, green:255, blue:255}
open theFile as EPS with options {class:EPS open options, mode:grayscale, resolution:600, use antialias:false, constrain proportions:true}
set docRef to the current document
tell the current document
set docName to name of docRef
set docBaseName to getBaseName(docName) of me
set newFileName to (outputFolder as string) & docBaseName
end tell
save docRef in file newFileName as TIFF with options {byte order:Mac OS, embed color profile:false, image compression:LZW, save alpha channels:false, save layers:false} appending lowercase extension with copying
close current document without saving
end tell
end repeat
-- Returns the document name without extension (if present)
on getBaseName(fName)
set baseName to fName
repeat with idx from 1 to (length of fName)
if (item idx of fName = ".") then
set baseName to (items 1 thru (idx - 1) of fName) as string
exit repeat
end if
end repeat
return baseName
end getBaseName