Detecting if a Path is present in an incoming image file

Post Reply
McCannManchester
Newbie
Posts: 16
Joined: Tue Sep 18, 2012 5:01 pm

Detecting if a Path is present in an incoming image file

Post by McCannManchester »

I was wondering if anybody has used a javascript in Switch to detect if an incoming image has a workpath/path without opening the file in photoshop first?



Having done a search on the internet I did find that somebody had used Javascript via Bridge to detect and rename a Path in an image file.



The reason behind the question is we send out a lot of images to be cutout, on receiving the files back sometimes they haven't named the path to Path 1 and left it as Workpath, sometimes the file coming back may be a jpeg or photoshop file with a Path.



What we would probably look to do is 1) check to see if a path is present 2) if so is the path named correctly if not rename to Path 1.



Any thoughts/suggestions



Thanks


freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Detecting if a Path is present in an incoming image file

Post by freddyp »

I do not have a turnkey solution for this, but what you could try is to use Imagemagick's identify command with the -verbose option. On an image on which I tried this it resulted in this output:



...



exif:XResolution: 3000000/10000

exif:YResolution: 3000000/10000

jpeg:colorspace: 2

jpeg:sampling-factor: 1x1,1x1,1x1

rdf:Alt:

signature: 1baefabc677612f5b01d7777d705497537c1e28d8a0ea558c320cfe76aee5735

xmpMM:DerivedFrom:

Clipping path:







<path style="fill:#00000000;stroke:#00000000;stroke-width:0;stroke-antialiasing:false" d="

M 163.268,1271.18

C 163.815,1265.38 164.409,1263.1 168.459,1257.74

C 172.509,1252.37 177.009,1248.48 179.062,1244.53

C 179.719,1239.72 179.959,1236.73 179.959,1234.33

C 179.215,1233.54 178.724,1233.24 178.735,1231.88

...



This at least shows that there is a clipping path in the file, but it does not show the name, at least not on the one file I tried it with. It may be worthwhile investigating your files with the Imagemagick tool to see if you can infer any information from it. If you can, it will be a lot easier to run Imagemagick from the command line and parse the output than it will be to parse the image file.



To run Imagemagick on the command line I used:

/opt/ImageMagick/bin/identify -verbose image_with_mask.jpg



Keep us posted.



Freddy
Evan
Member
Posts: 30
Joined: Mon Feb 28, 2011 6:44 pm

Detecting if a Path is present in an incoming image file

Post by Evan »

Use this script in the command section of photoshop configurator.



try

{

var newPathName = "Path "

var numberOfPaths = activeDocument.pathItems;

if (numberOfPaths.length > 0)

{

for (n =numberOfPaths.length-1; n>-1; n--) {

var a = numberOfPaths[n].kind;

if (a == "PathKind.NORMALPATH" && newPathName + n != numberOfPaths[n].name ){

numberOfPaths[n].name = newPathName + n;

}

if (a == "PathKind.WORKPATH" && newPathName + n != numberOfPaths[n].name ) {

numberOfPaths[n].name = newPathName + n;

}

}

}

}

catch(e)

{

$error = e

}

//PathKind.CLIPPINGPATH

//PathKind.NORMALPATH

//PathKind.TEXTMASK

//PathKind.VECTORMASK

//PathKind.WORKPATH

Post Reply