Page 1 of 1

Detect %VectorMaskedImagery in eps files

Posted: Thu Jul 12, 2012 8:55 am
by tkittel
Hello,



another little problem without a solution yet is to detect, if there are vector masks in photoshop eps files. The keyword should be "%VectorMaskedImagery". But I neither could found a integrated variable in switch11 for that property nor a solution to search for this keyword in the source code of eps files.

How to manage this challenge?



Have a nice day,

Thomas

Detect %VectorMaskedImagery in eps files

Posted: Thu Jul 12, 2012 4:01 pm
by dkelly
You could write a simple JS script to open and read the header of the EPS file until it finds the DSC comment %VectorMaskedImagery.



var epsFile = new File( job.getPath() );

if (epsFile.exists == false) {

job.fail( "Could not open EPSF file" );

} else {

epsFile.open(File.ReadOnly);

do {

var line = epsFile.readLine();

if (line.left(22) == "%VectorMaskedImagery:") {

job.log(1, "Found " + line);

job.setPrivateData("VectorMaskedImagery", line.mid(23));

job.sendToSingle(job.getPath());

break;

}

} while (!epsFile.eof);

epsFile.close();

}



Dwight Kelly

Apago, Inc.

dkelly@apago.com

Detect %VectorMaskedImagery in eps files

Posted: Fri Jul 13, 2012 10:47 am
by tkittel
Hello Dwight,



thank you for your javascript code. Unfortunately it runs in an infinite loop in my tests. I guess, it was caused in the colon after the search string "%VectorMaskedImagery:" which doesn't exist in my eps files. So I deleted the colon. I don't understand your "line.mid(23)" command, which perhaps was responsible, that the value of the new PrivateData key always stays empty (after deleting the colon).



With help of my colleague we tried the following code, which runs as expected:



// Is invoked each time a new job arrives in one of the input folders for the flow element.

// The newly arrived job is passed as the second parameter.

function jobArrived( s : Switch, job : Job )

{

var epsFile = new File( job.getPath() );

if (epsFile.exists == false) {

job.fail( "Could not open EPSF file" );

} else {

epsFile.open(File.ReadOnly);

var aFileContents = epsFile.readLines();

for(var i=0;i<aFileContents.length;i++) {

if(aFileContents.indexOf("%VectorMaskedImagery") >= 0){

job.setPrivateData("VectorMaskedImagery", "Vektordaten vorhanden");

break;

}

}

job.sendToSingle(job.getPath());





epsFile.close();

}

}





Thanks for your help!

Thomas

Detect %VectorMaskedImagery in eps files

Posted: Fri Jul 13, 2012 9:40 pm
by dkelly
I didn't have an example EPS to work with and guessed that the comment was DSC compliant. Hence the trailing ':' character.