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
output files:
...#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
Copy link to clipboard
Copied
anybody understand my requirement
Copy link to clipboard
Copied
anybody give solution this
i stuck
how to do this
Photoshop variable or any script
Copy link to clipboard
Copied
You want 18 spinners images. 5 red, 5 blue, 8 green. Try
Copy link to clipboard
Copied
very best comedy Sir
I want solution
I am learn scripting
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.
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.
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.
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.
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:)
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..
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);
};
Copy link to clipboard
Copied
thank you very much SuperMerlin
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
output came this kind of not taking the file name
kindly edit the script
thank you for your help
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)
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);
};