I am looking for a script that will simply check to see if an image has a Clipping Path. If it does have a Clipping Path, I'd like to move the file to a folder called "Images with Paths" and if it doesn't have Clipping Paths, I'd like to move the file to a folder called "Images need Paths". Any help would be greatly appreciated.
Thanks,
Danny
[CS4] Check If Image Has Clipping Path
[CS4] Check If Image Has Clipping Path
You can use this function to see if an open document has a clipping path.
Code: Select allfunction hasClippingPath(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet( ref );
var clippingPath = desc.getObjectValue(charIDToTypeID("Clpg"));
return clippingPath.getInteger(charIDToTypeID("ClpI" )) == -1 ? false:true;
};
For a more complete script I will need to know the paths to the save folders and if the script is to work in batch mode the source folder.
Code: Select allfunction hasClippingPath(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet( ref );
var clippingPath = desc.getObjectValue(charIDToTypeID("Clpg"));
return clippingPath.getInteger(charIDToTypeID("ClpI" )) == -1 ? false:true;
};
For a more complete script I will need to know the paths to the save folders and if the script is to work in batch mode the source folder.
[CS4] Check If Image Has Clipping Path
Thanks for your reply Mike. Here are the paths you needed.
The Batch Folder
file:///Users/enfocus/Desktop/Clipping%20Path%20Checker/
If it has a Clipping Path
file:///Users/enfocus/Desktop/Images%20with%20Clipping%20Paths/
If it doesn't have a Clipping Path
file:///Users/enfocus/Desktop/Images%20need%20Clipping%20Paths/
Thanks again,
Danny
The Batch Folder
file:///Users/enfocus/Desktop/Clipping%20Path%20Checker/
If it has a Clipping Path
file:///Users/enfocus/Desktop/Images%20with%20Clipping%20Paths/
If it doesn't have a Clipping Path
file:///Users/enfocus/Desktop/Images%20need%20Clipping%20Paths/
Thanks again,
Danny
[CS4] Check If Image Has Clipping Path
You might want to look at exiftool too… clipping path names are a tag… Photoshop ESP files contain the sting 'eoclip' if they are clipped. I have an AppleScript that I used do this with but I've NOT been able to convert it to JavaScript something in it that ESTK no like (mistery bytes in the string I think). Might save opening the files.
[CS4] Check If Image Has Clipping Path
Yes, if you have Exiftool you may be able to speed up the script by not opening the files in Photoshop. If the file has been saved at least once with Photoshop you can find the name of the clipping path with
-s -S -u -photoshop:clippingpathname pathToFile
No matter what format. e.i. tiff, jpeg, psd, eps, etc. If there is no clipping path that will return an empty string.
What format files are you working with?
-s -S -u -photoshop:clippingpathname pathToFile
No matter what format. e.i. tiff, jpeg, psd, eps, etc. If there is no clipping path that will return an empty string.
What format files are you working with?
[CS4] Check If Image Has Clipping Path
Mike, Its been some time since I last had to look at this. I was not using exiftool back then… If it finds Clipping Paths in Photoshop EPS's too then this is good to know, I used to have to treat these separately before. I don't use the EPS format myself any more at one time it was a must if you did page layout work in Quark.
[CS4] Check If Image Has Clipping Path
ExifTool....This is the first I've heard of this. We are currently using tif and psd files, but any file format could be coming in. Where would you recommend I download this tool from. It would be very nice if I didn't have to open the files. We are currently demoing the PowerSwitch from Enfocus. It is very scriptable, but all processes run on one Mac, so reading the file without opening it would be a huge bonus. Any more info as to where to get it and how to use it would be greatly appreciated. Thanks for all you're help so far.
Danny
Danny
[CS4] Check If Image Has Clipping Path
http://www.sno.phy.queensu.ca/~phil/exiftool/
This is a command line utility that has no user interface. Should be very fast.
This is a command line utility that has no user interface. Should be very fast.
[CS4] Check If Image Has Clipping Path
I've looked through the supplied link, and seeing how this is entirely new to me, I am thoroughly confused! How would I use ExifTool to determine if an image has a clipping path? What do you use to write the script for ExifTool?
I will definitely research ExifTool further. But to just get our flow going, how can I add arguments to the first JavaScript Mike generously supplied. If true move to a "Has Clipping Paths" Folder, if false, move to a "Needs Clipping Paths" Folder.
Anymore assistance with this would be great. Thanks for your help so far, you guys have been great.
Danny
I will definitely research ExifTool further. But to just get our flow going, how can I add arguments to the first JavaScript Mike generously supplied. If true move to a "Has Clipping Paths" Folder, if false, move to a "Needs Clipping Paths" Folder.
Anymore assistance with this would be great. Thanks for your help so far, you guys have been great.
Danny
[CS4] Check If Image Has Clipping Path
I have not tested this on a Mac but it works on Windows. Note that all the folders need to exists before running the script as it does not check.
Code: Select allvar sourceFolder = new Folder('/Users/enfocus/Desktop/Clipping Path Checker');
var withClipFolder = new Folder('/Users/enfocus/Desktop/Images with Clipping Paths');
var withoutClipFolder = new Folder('/Users/enfocus/Desktop/Images need Clipping Paths');
var files = sourceFolder.getFiles(function(file) { return (file.name.search(/\.psd$|\.tif$/i) != -1) });// get array of psd and tif files
for(var f=0;f<files.length;f++){
app.open(files[f]);
var hasClip = hasClippingPath();
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
var fName = decodeURI(files[f].name);
if(hasClip){
if(files[f].copy(new File(withClipFolder+'/'+fName))) files[f].remove();// if able to copy - remove original comment out files[f].remove(); if you only want to copy
}else{
if(files[f].copy(new File(withoutClipFolder+'/'+fName))) files[f].remove();
}
}
function hasClippingPath(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet( ref );
var clippingPath = desc.getObjectValue(charIDToTypeID("Clpg"));
return clippingPath.getInteger(charIDToTypeID("ClpI" )) == -1 ? false:true;
};
Code: Select allvar sourceFolder = new Folder('/Users/enfocus/Desktop/Clipping Path Checker');
var withClipFolder = new Folder('/Users/enfocus/Desktop/Images with Clipping Paths');
var withoutClipFolder = new Folder('/Users/enfocus/Desktop/Images need Clipping Paths');
var files = sourceFolder.getFiles(function(file) { return (file.name.search(/\.psd$|\.tif$/i) != -1) });// get array of psd and tif files
for(var f=0;f<files.length;f++){
app.open(files[f]);
var hasClip = hasClippingPath();
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
var fName = decodeURI(files[f].name);
if(hasClip){
if(files[f].copy(new File(withClipFolder+'/'+fName))) files[f].remove();// if able to copy - remove original comment out files[f].remove(); if you only want to copy
}else{
if(files[f].copy(new File(withoutClipFolder+'/'+fName))) files[f].remove();
}
}
function hasClippingPath(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet( ref );
var clippingPath = desc.getObjectValue(charIDToTypeID("Clpg"));
return clippingPath.getInteger(charIDToTypeID("ClpI" )) == -1 ? false:true;
};