• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

How to Export JPG files Scripting Automatically

Participant ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

I am having art and garment Group folder  separately , i want export the files form Red color garment with red Art, and blue color garment to blue color Art ,etc

Screen Shot 2017-07-20 at 7.33.44 PM.png

Example:

Screen Shot 2017-07-20 at 7.58.46 PM.png

TOPICS
Actions and scripting

Views

3.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 22, 2017 Jul 22, 2017

// if group of same name as layer exists save jpg of combinations of layer with each layer in group except if the layer is situated in the group;

// 2017, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

// jpg options;

var jpegOptions = new JPEGSaveOptions();

jpegOptions.quality = 9;

jpegOptions.embedColorProfile = true;

jpegOptions.matte = MatteType.NONE;

var myDocument = activeDocument;

var theName= myDocument.name.match(/(.*)\.[^\.]+$/)[1];

var thePath = myDocument.path;

// get

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

You would set the visible on of what you want visible and everything else visibility off and use Save As naming the file using some file naming convention. You may also be able to use layer comps and export layer comps.  I have never user then but I think they allow you to have different views of your documents

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

Thanks Mack

I am doing the same now . But tis need to be done automatic thru script is that possible .

Thanks in advance

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

Looking at the structure of your document.  to me it looks like you could script it. Turn all layers visibility off. Then loop through the garment group. Turn on a layer and loop through the color group for that color garment turn on a layer save out a file turn off the layer. when the color group has been processed. the garment loop turn off the current garment layer and moves onto the next garment.

Basically the script would be two loops. Garment loop and color group loop. Though I have processed all layer in a document with a recursive function  I have never process group of layer by group name.  So I would not know how one address a group by name. I would need to learn how to do that. 

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

thanks again JJ

this is for the PSD file link  https://we.tl/rPQhQSXmmX

this level of scripting I don't know

that's why I asked if Help

any possible other kind of way

Please help. Sorry for my bad english.

I appreciate your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

I understand you lack scripting knowledge.  So do I. I also have no interest in trying to script it for you. That is for you to do. Scripting is work I'm retired I do not need work.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

thank you for your help Sir

please suggest anybody

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

I sugested you may want to look into using layer comps.   I have not use them but the may make the job easier.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

not possible automation script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

You do not have the scripting knowledge and do not seem to want to try to develop a script.  I wrote from what I see I believe it could be automated using Photoshop scripting.

If you want a custom script you need to write it or have someone program it for you.

Personally I have no desire to program the process you want.  Scripting Photoshop is hard for me. I only do it when the process would be simple or  I have need for some process that requires the use of scripting using an action would be my first choice however Actions can not use logic. If I feel other users would find a script I write useful I make it available on the web.  Your process would require logic For if you did it manually and recorded your steps in an action. That action may only work on the document you recorded the action on. Turning on a layers viability in and action requires selecting layers by name  relatively addressing layers in actions only select visible layers. If the action works on the document used to record it. It may work on other document that have exactly the same structure same group names and  the same layer names you do not have duplicate group and layer names. If the document had more layers the would not be processes if a layer the action used was missing the action would fail.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

yes I will try action failed

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

can anybody help me

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

// if group of same name as layer exists save jpg of combinations of layer with each layer in group except if the layer is situated in the group;

// 2017, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

// jpg options;

var jpegOptions = new JPEGSaveOptions();

jpegOptions.quality = 9;

jpegOptions.embedColorProfile = true;

jpegOptions.matte = MatteType.NONE;

var myDocument = activeDocument;

var theName= myDocument.name.match(/(.*)\.[^\.]+$/)[1];

var thePath = myDocument.path;

// get layers and groupd;

var theArrays = getLayerAndGroupsNamesAndIDs();

var theLayers = theArrays[0];

var theGroups = theArrays[1];

// compare layer names to group names;

for (var m = 0; m < theLayers.length; m++) {

var thisName = theLayers[0];

selectLayerByID(theLayers[1],false);

var thisLayer = myDocument.activeLayer;

thisLayer.visible = false;

hideOthers ();

thisLayer.visible = true;

for (var n = 0; n < theGroups.length; n++) {

// if group has same name as layer;

if (thisName == theGroups[0]) {

  selectLayerByID(theGroups[1],false);

  var thisGroup = myDocument.activeLayer;

  thisGroup.visible = true;

// hide all layers in group:

  for (var p = 0; p < thisGroup.layers.length; p++) {thisGroup.layers

.visible = false};

// save one copy per layer in group;

  for (var o = 0; o < thisGroup.layers.length; o++) {

  thisGroup.layers.visible = true;

  myDocument.saveAs((new File(thePath+"/"+theName+"_"+theGroups[0]+"_"+String(o)+".jpg")),jpegOptions,true);

  thisGroup.layers.visible = false;

  }

  thisGroup.visible = false;

  }

}

};

myDocument.activeLayer = thisLayer;

thisLayer.visible = false;

};

////////////////////////////////////

function getLayerAndGroupsNamesAndIDs () {

// the file;

var myDocument = app.activeDocument;

// get number of layers;

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var applicationDesc = executeActionGet(ref);

var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));

// process the layers;

var theLayers = new Array;

var theGroups = new Array;

for (var m = 0; m <= theNumber; m++) {

try {

var ref = new ActionReference();

ref.putIndex( charIDToTypeID( "Lyr " ), m);

var layerDesc = executeActionGet(ref);

var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));

var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));

// if not layer group collect values;

if (layerSet != "layerSectionEnd" && layerSet != "layerSectionStart" && isBackground != true) {

var theName = layerDesc.getString(stringIDToTypeID('name'));

var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));

theLayers.push([theName, theID])

};

// if  layer group start;

if (layerSet == "layerSectionStart") {

var theName = layerDesc.getString(stringIDToTypeID('name'));

var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));

theGroups.push([theName, theID])

};

}

catch (e) {};

};

/*alert (theLayers.join("\n"));

alert (theGroups.join("\n"));*/

return [theLayers, theGroups]

};

// based on code by mike hale, via paul riggott;

function selectLayerByID(id,add){

add = undefined ? add = false:add

var ref = new ActionReference();

    ref.putIdentifier(charIDToTypeID("Lyr "), id);

    var desc = new ActionDescriptor();

    desc.putReference(charIDToTypeID("null"), ref );

       if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );

      desc.putBoolean( charIDToTypeID( "MkVs" ), false );

   try{

    executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );

}catch(e){

alert(e.message);

}

};

////// hide others //////

function hideOthers () {

var idShw = charIDToTypeID( "Shw " );

    var desc2 = new ActionDescriptor();

        var list1 = new ActionList();

            var ref1 = new ActionReference();

            ref1.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );

        list1.putReference( ref1 );

    desc2.putList( charIDToTypeID( "null" ), list1 );

    desc2.putBoolean( charIDToTypeID( "TglO" ), true );

executeAction( idShw, desc2, DialogModes.NO );

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

thank you very much c.pfaffenbichlerā€‹

result came this kind of

Screen Shot 2017-07-21 at 6.56.05 PM.png

output file this kind of come it's not show Art

Screen Shot 2017-07-21 at 6.57.54 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

Put the folders top-level.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

Screen Shot 2017-07-21 at 7.16.01 PM.png

this is for the PSD file link  https://we.tl/rPQhQSXmmX

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

Either adapt the Script or adapt the Fileā€™s layer- and folder-structure like this:

layersAndGroupsScr.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

thank you very much is working

It is possible this layer structure working the script?

you understand my English

Sorry for my bad english.

I appreciate your help!

Screen Shot 2017-07-21 at 8.04.44 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

If all you want is a shadow  for the shirt why not add a drop shadow layer style on the garment group why add unnecessary complexity. Removing the Art group simplified the scripting required  and the group itself served no real useful function and the structure you now show would most likely not even work the shadow layer you show if made visible would be clipped by the logo visible in the Art group and overlay the logo.

One of the reasons I did not want to program the script was I could not download your psd without allowing that site to use cookies on my machine.

With only top level groups the script process required is the loop within a loop I wrote about. Adding more group levels would complicate the scripting required. All the the ART group does is allow you to collapse you layers pallets and hide the layers that you have to see to manipulate their visibility. The ART Group add complexity you do not need.

You want an automate process to be as simple as it can be. The script will be easier to design and write and require less code and perform better because there is less code required..

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

this is for the Test file PSD file link

Test File.psd - Google Drive

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

OK I downloaded the file and look at it.  The Art group unifies the color groups and the clipped low opacity multiply neural shirt basically add an gradient overlay onto the logo.   The Art Group adds complexity to the document structure and as does the shadow layer. Both add complexity to any atomated process.

IMO there are alway more the one way to make a composite.  I want to remind you. You want to keep things as simple as posible if you want to automate the process. For a layer to be visible the group it is in must also be visible.  So if you remove your shadow layer move the color goup out of the art group and delete the art group you have a much less complex structure. IMO you can get your shadow by simply adding a gradient overlay layer style to the color groups.

The script handed to you will then do what you want.

Capture.jpg

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

layer comp working and good

why scripting is not working?

please advise

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

get a life...

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

I don't know understand sir

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 22, 2017 Jul 22, 2017

Copy link to clipboard

Copied

// if group of same name as layer exists save jpg of combinations of layer with each layer in group except if the layer is situated in the group;

// 2017, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

// jpg options;

var jpegOptions = new JPEGSaveOptions();

jpegOptions.quality = 9;

jpegOptions.embedColorProfile = true;

jpegOptions.matte = MatteType.NONE;

var myDocument = activeDocument;

var theName= myDocument.name.match(/(.*)\.[^\.]+$/)[1];

var thePath = myDocument.path;

// get layers and groupd;

var theArrays = getLayerAndGroupsNamesAndIDs();

var theLayers = theArrays[0];

var theGroups = theArrays[1];

// hide layers;

showHideByIdentifier (theLayers, false);

// show groups;

showHideByIdentifier (theGroups, true);

// compare layer names to group names;

for (var m = 0; m < theLayers.length; m++) {

var thisName = theLayers[0];

selectLayerByID(theLayers[1], false);

var thisLayer = myDocument.activeLayer;

thisLayer.visible = true;

for (var n = 0; n < theGroups.length; n++) {

// if group has same name as layer;

if (thisName == theGroups[0]) {

  selectLayerByID(theGroups[1],false);

  var thisGroup = myDocument.activeLayer;

// save one copy per layer in group;

  for (var o = 0; o < thisGroup.layers.length; o++) {

  thisGroup.layers.visible = true;

  myDocument.saveAs((new File(thePath+"/"+theName+"_"+theGroups[0]+"_"+String(o)+".jpg")),jpegOptions,true);

  thisGroup.layers.visible = false;

  }

  }

}

myDocument.activeLayer = thisLayer;

thisLayer.visible = false;

};

};

////////////////////////////////////

function getLayerAndGroupsNamesAndIDs () {

// the file;

var myDocument = app.activeDocument;

// get number of layers;

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var applicationDesc = executeActionGet(ref);

var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));

// process the layers;

var theLayers = new Array;

var theGroups = new Array;

for (var m = 0; m <= theNumber; m++) {

try {

var ref = new ActionReference();

ref.putIndex( charIDToTypeID( "Lyr " ), m);

var layerDesc = executeActionGet(ref);

var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));

var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));

// if not layer group collect values;

if (layerSet != "layerSectionEnd" && layerSet != "layerSectionStart" && isBackground != true) {

var theName = layerDesc.getString(stringIDToTypeID('name'));

var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));

theLayers.push([theName, theID])

};

// if  layer group start;

if (layerSet == "layerSectionStart") {

var theName = layerDesc.getString(stringIDToTypeID('name'));

var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));

theGroups.push([theName, theID])

};

}

catch (e) {};

};

/*alert (theLayers.join("\n"));

alert (theGroups.join("\n"));*/

return [theLayers, theGroups]

};

// based on code by mike hale, via paul riggott;

function selectLayerByID(id,add){

add = undefined ? add = false:add

var ref = new ActionReference();

    ref.putIdentifier(charIDToTypeID("Lyr "), id);

    var desc = new ActionDescriptor();

    desc.putReference(charIDToTypeID("null"), ref );

       if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );

      desc.putBoolean( charIDToTypeID( "MkVs" ), false );

   try{

    executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );

}catch(e){

alert(e.message);

}

};

// by mike hale, via paul riggott;

// http://forums.adobe.com/message/1944754#1944754

function selectLayerByIndex(index,add){

add = undefined ? add = false:add

var ref = new ActionReference();

    ref.putIndex(charIDToTypeID("Lyr "), index);

    var desc = new ActionDescriptor();

    desc.putReference(charIDToTypeID("null"), ref );

       if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );

      desc.putBoolean( charIDToTypeID( "MkVs" ), false );

   try{

    executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );

}catch(e){

alert(e.message);

}

};

////// show or hide layers by id //////

function showHideByIdentifier (theLayers, show) {

for (var x = 0; x < theLayers.length; x++) {

if (show == true) {var idShw = charIDToTypeID( "Shw " )}

else {var idShw = charIDToTypeID( "Hd  " )};

    var desc3 = new ActionDescriptor();

        var list2 = new ActionList();

            var ref2 = new ActionReference();

            ref2.putIdentifier( charIDToTypeID( "Lyr " ), theLayers[1] );

        list2.putReference( ref2 );

    desc3.putList( charIDToTypeID( "null" ), list2 );

executeAction( idShw, desc3, DialogModes.NO );

};

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines