Copy link to clipboard
Copied
Hi everyone
This is my first post in this Forum, and I think the answer to my question is rather simple for a pretty good programmer.
But I'm not
![]()
The problem is that im using a third party app. (Enfocus Switch) to run Photoshop CS3 and when it passes a "Photoshop EPS" to Photoshop it gets rasterized, Photoshop opens it as a "Generic EPS". What I need is some kind of javascript that tells PS to open the files as "Photoshop EPS". That script I have to place in "Switch" so it can tell Photoshop how to handle the files that it sends to it.
When the files are open everything works fine, mostly I'm running some simple macros on the images and some javascripting to save the files.
Thankful for any help or hint!
No you can't tell Photoshop to open a file without telling it which file you want it to open.
I don't want to install and learn a new app, but I did download the manual. It looks like it uses the $ for special global variables so you can try this
var file = $infile;
// or
//var file = $arg1
function openFile( file ){
var desc = new ActionDescriptor();
desc.putPath( charIDToTypeID( "null" ), new File( file ) );
executeAction( charIDToTypeID( "Opn " ), desc, DialogModes.NO );
}
If that doesn't
...Copy link to clipboard
Copied
Weclome to the forum. Here is how to open an eps file using javascript.
var epsOpts = new EPSOpenOptions();
epsOpts.antiAlias = true;
epsOpts.mode = OpenDocumentMode.CMYK;// other modes - GRAYSCALE, LAB, or RGB
epsOpts.resolution = 300;// pixels per inch
epsOpts.constrainProportions = true;
// if constrainProportions == true you can only set the width
// but if you don't set both Photoshop will throw a missing value error
epsOpts.width = new UnitValue( 7, 'in' )
epsOpts.height = new UnitValue( 5, 'in' );// height is ingored unless constrainProportions == false
var f = new File('~/My Documents/angie/soccer dude [Converted].eps' );
open( f, epsOpts );
Copy link to clipboard
Copied
Thank for the quick answer.
However, will this not treat the files as "Generic EPS" (rasterize, dimensions and so on)?
The files are sorted before they are passed to Photoshop so I know that there are no Illustrator or other vector-eps files among them.
I think that part of the prob. is that Photoshop is so to say "blind" until the file is opened.
The scriptinglistener doesn't record any open commands at all, otherwise it uses to be rather useful.
I'm getting so desperate that I've started to look at appletalk and automator to solve this.
But javascript should be much faster, and the workflow easier to control.
Copy link to clipboard
Copied
I guess that I do not understand what you are asking. Photoshop can open two types of eps files. Photoshop EPS and Generic EPS.
Photoshop EPS files do not need open options because the raster options are in the file. You can't tell Photoshop to open a generic eps as a Photoshop eps because it doesn't know how to rasterize it. You can open a generic eps using the open options then save the doc as a Photoshop eps so you will not need to set the options again the next time you open the file.
The code I posted opens a Generic EPS file and rasterize it using the open options. It sets the dimensions, color mode, and resolution.
Copy link to clipboard
Copied
Well, I can understand that this is a bit odd.
I think the most common problem with automated workflows, droplets and actions is that they may stop when they come upon a generic eps.
They will ask for resolution, colormode and so on.
This is almost the opposit, in the program I'm working with I only have two choises: Rasterize or use a script.
The choice I make will tell Photoshop what to do
If I choose rasterize, Photoshop will do as it is told, even with it's own eps-files.
The benefit of this is that the workflow crunches through every eps You possibly can throw at it.
The downside is that it destroys normal Photoshop files unless I can open them with a script.
I hope this clarifies the matter
![]()
Copy link to clipboard
Copied
I'm not sure this will work with the app you are using but I think the problem is that if you tell Photoshop to open an eps file with options those options are used even if the file is a Photoshop eps.
The function below will test an eps file to see if it's generic or Photoshop. If it's Photoshop it opens the file without options. If it's a generic eps it opens it with the supplied options
function openEPS( file, options ){
var test = file;
test.open('r');
var str = test.read();
test.close();
var res = str.search('Adobe Photoshop');
res = !!res;
if( res ){ // photoshop eps so open without options
open( file );
}else{// generic eps so supply options
open( file, options );
}
}
var epsOpts = new EPSOpenOptions();
epsOpts.antiAlias = true;
epsOpts.mode = OpenDocumentMode.CMYK;// other modes - GRAYSCALE, LAB, or RGB
epsOpts.resolution = 300;// pixels per inch
epsOpts.constrainProportions = true;
// if constrainProportions == true you can only set the width
// but if you don't set both Photoshop will throw a missing value error
epsOpts.width = new UnitValue(7, 'in' )
epsOpts.height = new UnitValue( 5, 'in' );// height is ingored unless constrainProportions == false
var f = new File('~/Desktop/soccer dude [Converted].eps' );
openEPS( f, epsOpts );
Copy link to clipboard
Copied
Thanks for your suggestion Michael but everytime I try something like that I only get a "Script returned error"-message.
Hovewer I do now understand the prob. is not really the eps-files.
It's the way my app passes the files to Photoshop, sorry for the missguiding.
As I wrote before I have two choises, "Automatic" or "Open by script".
Unfortunatly "Automatic" forces all eps-files to be rasterized.
The only thing scriptlike that worked so far is this codesnippet from scriptlistener.
var id1 = charIDToTypeID( "Opn " );
var desc1 = new ActionDescriptor();
var id2 = charIDToTypeID( "null" );
desc1.putPath( id2, new File( "/Users/Frozen/Desktop/Switch_TestFlow/InPut/TC9990701-IMG0722.eps" ) );
executeAction( id1, desc1, DialogModes.NO );
This opens that file in Photoshop without errors and all the macros work, but this of course only works on that particular file.
So if there is a way to write the code so it opens any file, that might work.
Maybe some kind of reg.exp that could replace the filename/path.
I'm lost!
Copy link to clipboard
Copied
You can turn that bit of scriptlistner code into a function that you can pass either a file object or string to for it to open the passed file.
var f = '~/My Documents/angie/soccer dude [Converted].eps';
// or
// var f = new File( '~/My Documents/angie/soccer dude [Converted].eps' );
openFile( f )
function openFile( file ){
var desc = new ActionDescriptor();
desc.putPath( charIDToTypeID( "null" ), new File( file ) );
executeAction( charIDToTypeID( "Opn " ), desc, DialogModes.NO );
}
But again I don't know if this will work with your app. It sounds like the app is not passing the arguments the script needs to work which is why you are getting the Script returned error"-message.
Copy link to clipboard
Copied
Well this is some progress I think.
It's a regular function and I don't get any errors.
![]()
But as before this will only work with the file that "var f" is referring to.
I think my app. tells photoshop which file to open so maybe I don't really need any filepath at all.
Is it possible just to tell Photoshop to open a file without referring to one?
B.T.W
The app I'm talking about is Enfocus FullSwitch and they have a fully working demo on their site.
Copy link to clipboard
Copied
No you can't tell Photoshop to open a file without telling it which file you want it to open.
I don't want to install and learn a new app, but I did download the manual. It looks like it uses the $ for special global variables so you can try this
var file = $infile;
// or
//var file = $arg1
function openFile( file ){
var desc = new ActionDescriptor();
desc.putPath( charIDToTypeID( "null" ), new File( file ) );
executeAction( charIDToTypeID( "Opn " ), desc, DialogModes.NO );
}
If that doesn't work you can try the others listed on page 149 and 150 of the manual or Enfocus support. Or check if they have a user forum. What you are doing isn't really Photoshop scripting, it's Enfocus Switch scripting.
Copy link to clipboard
Copied
Well, I did the same thing and the $infile is really the missing link.
Now I can use the function you made and maybe with the search for the "PhotoShop" string it can speed things up for me.
I'ts about 3,2 Tb of Images I have to open, flatten and compress so this is great.
Thanks for your help
Oh,Glory Days!!!
![]()
![]()
Find more inspiration, events, and resources on the new Adobe Community
Explore Now