• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Multiple artboards to multiple jpeg through script

Participant ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Hi,

I have the many artboards in single Photoshop document, so i need to export each art board as single JPEG file through script. I tried in some way but i got all the artboards in single jpeg instead different jpeg.

 

Please guide me how to export activeLayer (or all layers) as JPEG through script. We have the manual option in pilot menu of layer (screen shot attached).

 

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

doc.activeLayer = allLayers[x];

var docExportOptions = new ExportOptionsSaveForWeb;
var destFile = new File("~/Desktop/" + allLayers[x].name + ".jpg");
app.activeDocument.saveAs (destFile, docExportOptions, true, Extension.LOWERCASE);
}

 

I need to fix the image size, color space and, quality in export options, so please guide me on this.


Thanks in Advance...
Asuvath

TOPICS
Actions and scripting

Views

922

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
Adobe
Community Expert ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

I do not develop for the web and have never use Photoshop's  Artboard feature,  I have even removed the Artboard tool from my tool bar.  I looked at your pngs and the script code you posted.Layer_Export_Option.pngManual_Layer_Export.png

To me it look like Artboards may be like Layer Groups in your screen capture . Your Artboards are all visible and closed so we can not see any layers structures in the Artboard groups. In the Image Area it looks like  the artboards are spread accross the document.  Your other screen capture look like some export as jpeg of your artboards.  I took a quick look I took at the script code. It looked wrong to me.  It looked like you were setting new Export ]save for web options but using Save As  not export  as or export save for web.   That each document saved would have a file name that was the same as some layer name in the document and that layer would be the active layer in the document saved.   It look like the script is saving the active document with different names with different active layer.  In the code posted I do not see any code that seemed to be dealing with Artboards??? I would think that would require Action Manager code.

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 ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Thanks for the checking JJMack. Actually i am not posting complete code previously. Here i placed my complete code.

 

var doc = app.activeDocument;

var outputFolder = doc.path;

var allLayers = doc.layers;

var layNams = [];

var layTyp = [];

var artBrdLyr = [];

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

doc.activeLayer = allLayers[x];

if (isArtBoard()) {

var docExportOptions = new ExportOptionsSaveForWeb;
var destFile = new File("~/Desktop/" + allLayers[x].name + ".jpg");
app.activeDocument.saveAs (destFile, docExportOptions, true, Extension.LOWERCASE);

}

}

function isArtBoard() {

var ref = new ActionReference();

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

return executeActionGet(ref).getBoolean(stringIDToTypeID("artboardEnabled"));

}

Please note, i am tried Action Manager code also, but it is not running.
Can you please guide me to get out from this issue?

Thanks

Asuvath

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 ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

I only hack at scripting Photoshop you need some help from someone that know Jacascript and also how  to script Photoshop well including Action manager code.  I don't.  There are not many around here these days that do.  Paul left years ago. I have not  seen X post anything lately. Mike passed away,  Supermerlin shows up now and and then. R-bin been very helpful, Kukurykus is very good but I can't even follow his advance coding styles.  Chuck may be helpful perhaps  Jazz-y will. Once in a while other that seem to know  Photoshop scripting chime in.

 

I'm have never used an Artboard I have no idea how you work with Artboards. I don't have a cell Phone my wife has a iPhone I don't touch I want the keep my hands safe.

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 ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

Hi JJMack,

 

Thank you somuch for your guidance and details about PS experts. So sad for lost those experts. I am learning the Action Manager code also.

 

Me too, this is the first time to meet the Artboard related scripts in Photoshop. Lets wait for other experts replies on this.

 

thanks

Asuvath

 

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 ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

Photoshop ships with the File > Export > Artboards To Files script, have you tried that?

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 ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

Hi Stephen,


Yes i tried. This is manual process, but i need this process as scripted for multiple documents as automation. So please help me on this.

 

Thanks

Asuvath

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 ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

Hi Asuvath, I'm only a beginner and this is rather complex.

 

In the short term, I would opt for semi-automation over full automation. It's of course a trade off in being there to attend the batch and pressing the return key vs the time spent to script the full unattended automation. Semi-automation is better than nothing...

 

By creating an action and using the "insert menu item" command:

* Layer > Select All Layers

* File > Export > Artboards To Files...

 

Then use File > Automate > Batch...

 

You will need to press the return/enter key on the keyboard twice per file. By editing the original script, you can remove the "Artboards To Files was successful" message and reduce this to one click per file in the batch.

 

I know that this is not ideal, however, it is pragmatic.

 

Good luck, I'll let you know if I can help further.

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 ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

I will try this option. Thanks for checking Stephen.

 

Thanks

Asuvath

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
LEGEND ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

LATEST

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