• 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 separate Fidget Spinner Export JPG files Scripting

Participant ,
Jul 27, 2017 Jul 27, 2017

Copy link to clipboard

Copied

How to do export files JPG

any script or any other method

18 output JPG files

this is for the Test file PSD file link Fidget Spinner Test Files - Google Drive

kindly advise

Screen Shot 2017-07-27 at 5.56.11 PM.png

Screen Shot 2017-07-27 at 11.59.14 PM.png

output files:

Screen Shot 2017-07-28 at 12.05.48 AM.png

TOPICS
Actions and scripting

Views

1.0K

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

Guide , Jul 29, 2017 Jul 29, 2017

#target photoshop;

app.bringToFront();

if(documents.length) main();

function main(){

var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');

var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");

if(csv == null) return;

outputFolder = Folder.selectDialog("Please select the output folder");

if(outputFolder == null) return;

csv.open('r');

var data = csv.read();

csv.close();

data=data.split("\n");

var data2=[];

for(var a in data){

    if(a==0) continue;

    var line = data.split(",");

    if(li

...

Votes

Translate

Translate
Adobe
Participant ,
Jul 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

anybody understand my requirement

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 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

anybody give solution this

i stuck

how to do this

Photoshop variable or any 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 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

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 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

very best comedy Sir

I want solution

I am learn scripting

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 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

saranr37921948  wrote

very best comedy Sir

I want solution

I am learn scripting

I was not trying to be a comic.  You posted a layered PSD file that has three layers one each has a an image of a single spinner. One Red, one Green, one blue,  You posted you want 18 spinners jpg and poster 19 row two column list containing 18 file names and an associated color red, green, or blue. You ask if any one understood your requirements.  You want jpeg from ]from Photoshop.  What Photoshop steps are you trying to script. Show us what you have so far so we get some Idea of the process you are trying to automate. You gave us no information as to how you want the generate these files. You ask ho to separate the spinners. Your PSD has them on separate layers. They seem to be separated already??? One of your appends also seemed to indicate you may be using Photoshop data driven graphics for you stated Photoshop variable  which goes along with a PSD and a Row and Column CSV file. However, your PSD does not look like a Data Driver Graphics template. I think the only one who understand what you want may be yourself.

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
Community Expert ,
Jul 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

JJMack, my “understanding” is:

Create a script to cycle through a red, green, blue layered file. The script should perform a lookup from a .CSV file matching the “Fidget Spinner Color” column value to the appropriate layer name to switch on visibility and save out a new file with the name found in the “File Naming” column for that colour.

If this was only 18 files, this could have easily be done manually in less than 5 minutes, so I’m guessing that this is either an ongoing requirement or the list is actually a lot longer than 18 files.

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 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

That could be what they want. It is just hard for me to believe they want five copies of a red spinner image, five copies of a blue spinner and eight copies of a green spinner  with coded file names like they show.

rgbspinners.png

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 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

i don't know how to explain in english

kindly see the screenshot I want this kind of output

Create a script to cycle through a red, green, blue layered file. The script should perform a lookup from a .CSV file matching the “Fidget Spinner Color” column value to the appropriate layer name to switch on visibility and save out a new file with the name found in the “File Naming” column for that colour.

Screen Shot 2017-07-29 at 9.52.22 AM.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
Participant ,
Jul 28, 2017 Jul 28, 2017

Copy link to clipboard

Copied

thank you sir my requirement you understand

this is my requirement

Create a script to cycle through a red, green, blue layered file. The script should perform a lookup from a .CSV file matching the “Fidget Spinner Color” column value to the appropriate layer name to switch on visibility and save out a new file with the name found in the “File Naming” column for that colour.

I have 1000 files:)

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 29, 2017 Jul 29, 2017

Copy link to clipboard

Copied

You do not need Photoshop to do file copying. All you would be doing with that script is copying your three images.  It would be very easy with a text editor to make a DOS BAT file using your CVS file to copy the three images jpeg files you started with.  You do not need complicate things  stack the images into a layered document then script the process.  It a simple file copy you are doing..

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
Guide ,
Jul 29, 2017 Jul 29, 2017

Copy link to clipboard

Copied

#target photoshop;

app.bringToFront();

if(documents.length) main();

function main(){

var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');

var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");

if(csv == null) return;

outputFolder = Folder.selectDialog("Please select the output folder");

if(outputFolder == null) return;

csv.open('r');

var data = csv.read();

csv.close();

data=data.split("\n");

var data2=[];

for(var a in data){

    if(a==0) continue;

    var line = data.split(",");

    if(line.length ==2)

    data2.push([[line[0].toString().replace(/^\s+|\s$/g,"").replace(/File Name$/,Name)],[line[1].toString().replace(/^\s+|\s$/g,"")]]);

    }

data=[];

setLayersVisOFF();

for(var x in data2){

    if(selectLayerByName(data2[1].toString())){

    app.activeDocument.activeLayer.visible = true;

    var saveFile = new File(outputFolder +"/" + data2[0].toString() + ".jpg");

    SaveForWeb(saveFile,80);

    app.activeDocument.activeLayer.visible = false;

    }

    }

};

function setLayersVisOFF(){

   var ref = new ActionReference();

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

   var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;

try{

    activeDocument.backgroundLayer;

var i = 0; }catch(e){ var i = 1; };

   for(i;i<count;i++){

        ref = new ActionReference();

        ref.putIndex( charIDToTypeID( 'Lyr ' ), i );

        var desc = executeActionGet(ref);

        var layerName = desc.getString(charIDToTypeID( 'Nm  ' ))

        if(layerName.match(/^<\/Layer group/) ) continue;

        var layerType = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'layerSection' )));

        var isLayerSet =( layerType == 'layerSectionContent') ? false:true;

        if(desc.getBoolean(stringIDToTypeID('visible')) && isLayerSet != true){

            var list = new ActionList();

            list.putReference( ref );

            desc.putList( charIDToTypeID('null'), list );

            executeAction( charIDToTypeID('Hd  '), desc, DialogModes.NO );

            }

   };

};

function selectLayerByName(lyrName){

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putName( charIDToTypeID( "Lyr " ), lyrName);

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

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

try{

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

}catch(e){return null;}

};

function SaveForWeb(saveFile,jpegQuality) {

var sfwOptions = new ExportOptionsSaveForWeb();

   sfwOptions.format = SaveDocumentType.JPEG;

   sfwOptions.includeProfile = false;

   sfwOptions.interlaced = 0;

   sfwOptions.optimized = true;

   sfwOptions.quality = jpegQuality;

activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

};

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 29, 2017 Jul 29, 2017

Copy link to clipboard

Copied

thank you very much SuperMerlin

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 31, 2017 Jul 31, 2017

Copy link to clipboard

Copied

the script not taking the file name the original file

the script now taking the CVS filenaming

I want taking the CVS to File Naming + original PSD file name

Example naming

MVI_FidgetSpinner.jpg

Screen Shot 2017-08-01 at 12.07.27 PM.png

output came this kind of not taking the file name

Screen Shot 2017-08-01 at 12.10.21 PM.png

kindly edit the script

thank you for 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
Guide ,
Aug 01, 2017 Aug 01, 2017

Copy link to clipboard

Copied

LATEST

#target photoshop;

app.bringToFront();

if(documents.length) main();

function main(){

var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');

var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");

if(csv == null) return;

outputFolder = Folder.selectDialog("Please select the output folder");

if(outputFolder == null) return;

csv.open('r');

var data = csv.read();

csv.close();

data=data.split("\n");

var data2=[];

for(var a in data){

    if(a==0) continue;

    var line = data.split(",");

    if(line.length ==2)

    if(line[0].toString().replace(/^\s+|\s$/g,"").match(/File Name$/)){

    data2.push([[line[0].toString().replace(/^\s+|\s$/g,"").replace(/File Name$/,Name)],[line[1].toString().replace(/^\s+|\s$/g,"")]]);

    }else{

       data2.push([[(line[0].toString().replace(/^\s+|\s$/g,"") +"_" +Name)],[line[1].toString().replace(/^\s+|\s$/g,"")]]);

       }

    }

data=[];

setLayersVisOFF();

for(var x in data2){

    if(selectLayerByName(data2[1].toString())){

    app.activeDocument.activeLayer.visible = true;

    var saveFile = new File(outputFolder +"/" + data2[0].toString() + ".jpg");

    SaveForWeb(saveFile,80);

    app.activeDocument.activeLayer.visible = false;

    }

    }

};

function setLayersVisOFF(){

   var ref = new ActionReference();

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

   var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;

try{

    activeDocument.backgroundLayer;

var i = 0; }catch(e){ var i = 1; };

   for(i;i<count;i++){

        ref = new ActionReference();

        ref.putIndex( charIDToTypeID( 'Lyr ' ), i );

        var desc = executeActionGet(ref);

        var layerName = desc.getString(charIDToTypeID( 'Nm  ' ))

        if(layerName.match(/^<\/Layer group/) ) continue;

        var layerType = typeIDToStringID(desc.getEnumerationValue( stringIDToTypeID( 'layerSection' )));

        var isLayerSet =( layerType == 'layerSectionContent') ? false:true;

        if(desc.getBoolean(stringIDToTypeID('visible')) && isLayerSet != true){

            var list = new ActionList();

            list.putReference( ref );

            desc.putList( charIDToTypeID('null'), list );

            executeAction( charIDToTypeID('Hd  '), desc, DialogModes.NO );

            }

   };

};

function selectLayerByName(lyrName){

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putName( charIDToTypeID( "Lyr " ), lyrName);

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

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

try{

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

}catch(e){return null;}

};

function SaveForWeb(saveFile,jpegQuality) {

var sfwOptions = new ExportOptionsSaveForWeb();

   sfwOptions.format = SaveDocumentType.JPEG;

   sfwOptions.includeProfile = false;

   sfwOptions.interlaced = 0;

   sfwOptions.optimized = true;

   sfwOptions.quality = jpegQuality;

activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

};

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