Jump to content

miletbaker

Members
  • Posts

    11
  • Joined

  • Last visited

Reputation Activity

  1. Like
    miletbaker got a reaction from Alealokato in Photoshop to Spriter (Photoshop Plugin attached)   
    Hi all,
    This isn't a Spriter Plugin, but a handy Photoshop one to export to Spriter. I have been working on improving my workflow and have written a simple Photoshop script to exports the contents of each top level layer group into a separate flattened png file for use as in Spriter. For example if you have layers organised as per attached image.
    The script creates a subfolder in the same directory as the psd, named with the psd's name and within (in this example) would be:
    head.png (which would have merge the sub group too)
    r_forearm.png
    r_upper_arm.png
    l_upper_arm.png
    body.png
    (In the example image the ungrouped layer1, a scanned image I am tracing from, is not exported)
    As I can't upload jsx files, just copy and paste the script below into your text editor and save it as 'Export Layer Groups to PNGs.jsx' and copy the file to your Photoshop CS6/Presets/Scripts folder. You can then access the command (after a restart) from File > Scripts > Export Layer Groups to PNGs
    I have only tested on CS6 but pretty sure it will work on CS5

    #target photoshop
    function main(){
    if(!documents.length) return;
    var doc = activeDocument;
    var oldPath = activeDocument.path;
    var docname = doc.name.replace('.psd', '');
    new Folder(oldPath + "/" + docname).create();
    for(var a=0;a activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets[a].name);
    dupLayers();
    activeDocument.mergeVisibleLayers();
    activeDocument.trim(TrimType.TRANSPARENT,true,true,true,true);
    var saveFile= File(oldPath + "/" + docname + "/" + doc.layerSets[a].name +".png");
    SavePNG(saveFile);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }
    }
    main();
    function dupLayers() {
    var desc143 = new ActionDescriptor();
    var ref73 = new ActionReference();
    ref73.putClass( charIDToTypeID('Dcmn') );
    desc143.putReference( charIDToTypeID('null'), ref73 );
    desc143.putString( charIDToTypeID('Nm '), activeDocument.activeLayer.name );
    var ref74 = new ActionReference();
    ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc143.putReference( charIDToTypeID('Usng'), ref74 );
    executeAction( charIDToTypeID('Mk '), desc143, DialogModes.NO );
    };

    function SavePNG(saveFile){
    pngSaveOptions = new PNGSaveOptions();
    activeDocument.saveAs(saveFile, pngSaveOptions, true,Extension.LOWERCASE);
    }

  2. Like
    miletbaker got a reaction from IzbranniY in Photoshop to Spriter (Photoshop Plugin attached)   
    Hi all,
    This isn't a Spriter Plugin, but a handy Photoshop one to export to Spriter. I have been working on improving my workflow and have written a simple Photoshop script to exports the contents of each top level layer group into a separate flattened png file for use as in Spriter. For example if you have layers organised as per attached image.
    The script creates a subfolder in the same directory as the psd, named with the psd's name and within (in this example) would be:
    head.png (which would have merge the sub group too)
    r_forearm.png
    r_upper_arm.png
    l_upper_arm.png
    body.png
    (In the example image the ungrouped layer1, a scanned image I am tracing from, is not exported)
    As I can't upload jsx files, just copy and paste the script below into your text editor and save it as 'Export Layer Groups to PNGs.jsx' and copy the file to your Photoshop CS6/Presets/Scripts folder. You can then access the command (after a restart) from File > Scripts > Export Layer Groups to PNGs
    I have only tested on CS6 but pretty sure it will work on CS5

    #target photoshop
    function main(){
    if(!documents.length) return;
    var doc = activeDocument;
    var oldPath = activeDocument.path;
    var docname = doc.name.replace('.psd', '');
    new Folder(oldPath + "/" + docname).create();
    for(var a=0;a activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets[a].name);
    dupLayers();
    activeDocument.mergeVisibleLayers();
    activeDocument.trim(TrimType.TRANSPARENT,true,true,true,true);
    var saveFile= File(oldPath + "/" + docname + "/" + doc.layerSets[a].name +".png");
    SavePNG(saveFile);
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }
    }
    main();
    function dupLayers() {
    var desc143 = new ActionDescriptor();
    var ref73 = new ActionReference();
    ref73.putClass( charIDToTypeID('Dcmn') );
    desc143.putReference( charIDToTypeID('null'), ref73 );
    desc143.putString( charIDToTypeID('Nm '), activeDocument.activeLayer.name );
    var ref74 = new ActionReference();
    ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc143.putReference( charIDToTypeID('Usng'), ref74 );
    executeAction( charIDToTypeID('Mk '), desc143, DialogModes.NO );
    };

    function SavePNG(saveFile){
    pngSaveOptions = new PNGSaveOptions();
    activeDocument.saveAs(saveFile, pngSaveOptions, true,Extension.LOWERCASE);
    }

×
×
  • Create New...