PhotoshopForums.com Home
Navigate Contact FAQ Search Members
CS4 Action to select only layers with clipping mask
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation
 See a User Guidelines violation? Please contact us.
Author Message

whainsjr

Joined: 10 Feb 2010
Posts: 1



PostPosted: Wed Feb 10, 2010 2:02 pm    Post subject: CS4 Action to select only layers with clipping mask Reply with quote

Hi,
I need to create a action is CS4 that will allow me to open a psd, select only the layers with clipping mask applied, extract the entire image, and save those images individually.

I have 1000's of psd's to go through in which I need to extract the all of the stock photos out of. So each psd could have up to 5 photos included and I need to create an action that will do this for me.

Anyone have any ideas on the best way to do this with actions, or is this not possible. I have thousands of psd's I need to go through.

Thanks

_________________
William
View user's profile Send private message

Paul R

Joined: 06 Apr 2010
Posts: 57



PostPosted: Tue Apr 06, 2010 8:40 am    Post subject: Reply with quote

This should be no problem for a script. What format would you like the output to be?
Here is an example saving to psd.
Code:

main();
function main(){
if(!documents.length) return;
var doc = activeDocument;
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var Path = decodeURI(doc.path);
for (var a = 0 ; a< activeDocument.artLayers.length;a++){
    activeDocument.activeLayer = activeDocument.artLayers[a];
    if(isClippingLayer()) {
        var NewDocName = decodeURI(Name+"-"+activeDocument.activeLayer.name);
        dupLayers(NewDocName);
        var saveFile = File(Path+"/"+NewDocName +".psd");
        SavePSD(saveFile);
        activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }
   }
}   
   
function isClippingLayer(){
   var layer = activeDocument.activeLayer;
   return (layer.grouped == true && layer.kind == LayerKind.NORMAL)
};
function dupLayers(NewDocName) {
    var desc143 = new ActionDescriptor();
        var ref73 = new ActionReference();
        ref73.putClass( charIDToTypeID('Dcmn') );
    desc143.putReference( charIDToTypeID('null'), ref73 );
    desc143.putString( charIDToTypeID('Nm  '), NewDocName );
        var ref74 = new ActionReference();
        ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc143.putReference( charIDToTypeID('Usng'), ref74 );
    executeAction( charIDToTypeID('Mk  '), desc143, DialogModes.NO );
};
function SavePSD(saveFile){
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true; 
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
};
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Contact - User Guidelines >

Copyright © 2003-2016. PhotoshopForums.com, iFroggy Network. All Rights Reserved.
Powered by phpBB © phpBB Group. phpBB SEO. Privacy Policy.
We are in no way affiliated with Adobe. Photoshop, Adobe and related marks are registered trademarks of Adobe.
PhotoshopForums.com