Scripting Photoshop CS3 to rasterize EPS files...

Whenever you drag an eps file onto the photoshop icon, you are presented with the dialog box that says “Rasterize Generic EPS Format” along with options on sizing. Does anyone know how to control this behavior with a script? I have been trying to write a script that will tell photoshop to open an eps file and set it’s height and width to 200%, then save the resulting file as a jpeg. I am very frustrated as I haven’t come close to figuring out how to do this. Any ideas?

Jonathan

Use the following in open line, adjusting the settings as needed.

open alias "FilePath:FileName" as EPS with options {class:EPS open options, height:percent 100, width:percent 100, mode:CMYK, resolution:350, use antialias:false, constrain proportions:true} showing dialogs never

I also need to do this. But, in the following extract from the code:

even though I have written as percent 180, it creates the eps with 180/100 pixels, and I think it always takes the value as pixels and the percent string only gives the value/100. I tried:

  • still the same problem persists. I also tried:

Still in vain. Kindly help.

hmmmm…I have a script for building templates for cover design that it works (or at least worked) fine in, however it does not seem to be working now. Try this, it seems to be working for me when testing it at 100 for height and 72 for resolution as well as 180 and 72 and 180 and 100:

set myFile to choose file
tell application "Adobe Photoshop CS2"
	set ruler units of settings to percent units
	open myFile as EPS with options {class:EPS open options, height:180, width:180, mode:CMYK, resolution:72, use antialias:false, constrain proportions:true} showing dialogs never
end tell

Does not work… It rasterizes the file in the specified pixels (180), not increased by 180%.

I don’t have CS3 but you could give this a try. Instead of specify height & width leave out and multiply your res by % the file should be rasterized at 100% of actual dimensions. Then just perform as resize without sampling. You should end up with the same thing just doing the math backwards. Don’t know if this is going to help.

set myFile to choose file
tell application "Adobe Photoshop CS2"
	activate
	open myFile as EPS with options {class:EPS open options, mode:CMYK, resolution:(72 * 1.8), use antialias:false, constrain proportions:true} showing dialogs never
	set Doc_Ref to the current document
	tell Doc_Ref
		resize image resolution 72 resample method none
	end tell
end tell

OK, I knew that I had it working once. The original line of code that I posted was for CS. This should still work according to the open as EPS options in the library but as noted it is not working as expected. Marks solutions appears to be a satisfactory workaround to the problem. Though from Adobe’s own documentation in CS3 the percent should work:

tell application "Adobe Photoshop CS3"
set myFilePath to alias "Data:docsamples:testfiles:AI11.eps"
open myFilePath as EPS with options ¬
{class:EPS open options, height:pixels 100,¬
width:pixels 200, mode:RGB, resolution:72, ¬
use antialias:true, constrain proportions:true}
end tell

Done!!!
Mark’s code worked and given exactly what I want. Thanks a lot…!!!

Jerome, it looks like the testing went as far as the example quoted. The measurement bugs were well known in CS2 when I started playing with scripting (I now always use pixel measures in script) They even claim to have fixed using “percent”:

● The resize image command now behaves correctly for percentages. In CS2, it was off by 2 decimal places. (E.g 25% = 0.25)

The work around is straight forward enough (thankfully) I won’t be in a rush to migrate to CS3.