0

How could I export all my clipping masks (the clipping masks in different colors and pattern - 32 clipping masks) in one go with a single asset/model?

My normal approach is to export manually, one by one of the clipping masks which consumes a lot of times. When I am using the export → Layers to files → it only export out all the clipping masks without the asset/model in it.

Any work around of these?

  • hello and welcome GDSE. can you explain more of your question like which type of layers your psd contains and which kind of pattern of export you are talking! Thanks :) – Mr.Online May 30 at 3:05
  • Hi Design Phoenix, it is a pattern layer more than 50 design pattern. My question is similar to this post link below, but it seems that the post yet to receive any solution. Thanks!graphicdesign.stackexchange.com/questions/37930/… – Dony Koh May 30 at 8:42
  • as far as i understand assume you have 20 clipping mask and 20 layers clipped so your layer panel are like " clipping layer - clipping mask - clipping layer - clipping mask..." right? if you won't mind can you share screenshot of your layer panel or anything related it because to make script i need the layer details etc :) thanks! – Mr.Online May 30 at 9:16
1

I presume you have a bunch of clipping masks and a base layer and you want to export every clipping mask + the base layer as a separate png.

enter image description here

This script will ask for an output folder, select the top layer and then will start to save pngs, hide current clipping mask and select a layer below. Names will be documentName_layerIndex.png

Result:

enter image description here

function main()
{
    if (documents.length == 0) return false;

    var outputFolder = Folder.selectDialog('', new Folder(Folder.myDocuments));

    if (outputFolder == null) return false;

    var doc = activeDocument,
        docName = doc.name.split('.')[0],
        counter = 1;

    doc.activeLayer = doc.layers[0];

    while (doc.activeLayer.grouped)
    {
        saveForWebPng(outputFolder + "/" + docName + "_" + counter + ".png");
        doc.activeLayer.visible = false;
        selectPreviousLayer();
        counter++
    };

    function saveForWebPng(saveFile)
    {
        var pngOpts = new ExportOptionsSaveForWeb;
        pngOpts.format = SaveDocumentType.PNG
        pngOpts.PNG8 = false;
        pngOpts.transparency = true;
        pngOpts.interlaced = false;
        pngOpts.quality = 100;
        activeDocument.exportDocument(new File(saveFile), ExportType.SAVEFORWEB, pngOpts);
    }; // end of saveForWebPng()

    function selectPreviousLayer() {
        var desc = new ActionDescriptor();
        var ref = new ActionReference();
        ref.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Bckw'));
        desc.putReference(cTID('null'), ref);
        desc.putBoolean(cTID('MkVs'), false);
        executeAction(cTID('slct'), desc, DialogModes.NO);
    }; // end of selectPreviousLayer()

    function cTID(s)
    {
        return app.charIDToTypeID(s);
    };

    function sTID(s)
    {
        return app.stringIDToTypeID(s);
    };


}
app.activeDocument.suspendHistory("temp", "main()");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.