Copy link to clipboard
Copied
I'm trying to auto-compose and export 1000s of combinations of layers across multiple layer groups. I understand I probably need to feed a script to make this work. I have a PSD file with 8 different LayerGroups. Each LayerGroup between 1-30 different layers. I want to feed instructions to batch export (PNG) specific combinations.
E.g.
Final PNG 1 = LayerGroup 1:layer 3 + LayerGroup 2:layer 7 + ... + LayerGroup 8:layer 87
Final PNG 2 = LayerGroup 1:layer 2 + LayerGroup2:none + ... + LayerGroup 8:layer 94
...
Final PNG 1000 = Layer gruop 1:none + Layer group 2:layer 8 + ... + Layer group 3:layer 92
I saw PhotoshopCompositionComposer javascript on GitHub - but it throws an error, I'm working in latest Photoshop 22.4.2 Release. Any help would be appreciated.
Copy link to clipboard
Copied
Without a description of the specific structure, as well as an algorithm for what exactly you want to display in the current PNG, it is hardly possible to solve the problem. Your script seems to leave one visible layer in each folder for the next combination. Not sure if this is what you want. What kind of error does it give? And also give the exact link to the script if you want to fix it.
Copy link to clipboard
Copied
Here's a better understanding of the structure (actual structure has ~8 folders, and ~100 individual layers):
Folder 1: HAIR
Folder 2: GLASSES
Folder 3: MOUTH
Folder 4: JEWELRY
Folder 5: FACE
I want to be able to feed it specific instructions on which single layers to use, e.g.:
Export PNG 1 = Folder1:layer3 + Folder2:layer5 + Folder3:layer8 + Folder5:layer14
This will export a "round face" with "aviator" glasses, "medium" hair, "closed" mouth, and NO jewelry (since no layers from Folder 4 were specified).
In the script - i will instruct the specific ~1,000+ combinations I'm looking for (e.g. 1,000+ final PNGs).
The canvas is only 24x24 pixels - so the file (and the layers) is quite small.
I was able to get the PhotoshopCompositionComposer script to work - but the way it works, is it produces every possible combination across the Folders - in my case, it was going to create 89K PNGs - which was going to take my laptop 3+ days of processing (based on the time it took to make ~20 before I shut it down). I'd rather just have a script with the specific 1,000 combos defined - using the processing power only to produce those combos. Does this better explain it? Thanks in advance!
Copy link to clipboard
Copied
@posvar Are you on a mac or PC? thanks!
Copy link to clipboard
Copied
PC - I just provided a more detailed breakdown of what I'm trying to do in the response above. I was able to get the PhotoshopCompositionComposer script to work - but it produces every possible combination across the Folders, in my case 89K+ PNGs would be created, taking multiple days of non-stop processing. I'd prefer an approach where I can instruct the specific ~1K combos I'm targeting. Thanks in advance.
Copy link to clipboard
Copied
If you can not figure out script be aware that data sets can be used to show/hide layers and layer groups. At least you have alternative solution.
Copy link to clipboard
Copied
what is this feature called? Can PS use a dataset to compose layer combinations and export bulk PNGs? Where can I read more aobut how to do this? Thanks in advance.
Copy link to clipboard
Copied
You can not export PNG files but rather PSD which can be bulk converted to PNG.
Here is official help page Create data-driven graphics
Here are my tutorials on that topic Easy Way to Automate Photoshop with Variables At the bottom zou have links to more connected tutorials.
Copy link to clipboard
Copied
Playing with this Dataset feature - thanks. Seems to be what I need. Wish there were a way to "export" the CSV file of all the "variables" - so I can create my CSV offline and "import" it. I have 100+ variables, so it's time-consuming to recreate that in XLS as a first step. Is there an easy "export variable list" feature somewhere?
Copy link to clipboard
Copied
No built in functionality. You can accept default naming convention and perhaps automate data creation in excel.
Copy link to clipboard
Copied
Yeah - I had to re-write the 100+ variable names in XLS to build the import file - was a pain, and made many errors before the import worked.
This solution seems to work so far - it's worked with an import of a batch of ~100 data sets. True test is next - whether it can accept a batch of ~2K data sets 🙂
Thanks Bojan for your support!
Copy link to clipboard
Copied
I am not aware of any limitation, especially to show/hide layers in the file. Good luck, I tried several times to import and scale 50+ images for several exported files and it worked. Your task is easier and it should work with 2000 instructions (I think you are reffering 20 data sets x 100 variables). One data set is actually one line of data, in your case that will be 100 true or false.
Copy link to clipboard
Copied
2000 data sets (100 instructions in each dataset).
It worked with 88 data sets (100 instructions) - still building my full universe of data sets so I haven't tested yet.
Copy link to clipboard
Copied
hi,
I have a very similar project with racing seats. Is there anyway you could share your csv?
I need to hide x layers , show y layers export png, repeat 10,000
I think I have got the concept down, I just need to know how to format the excel sheet to get a correct data set .
Once I see a good example I can populate with my variables.
Copy link to clipboard
Copied
You can not export PNG files but rather PSD which can be bulk converted to PNG.
By @Bojan Živković
This is correct, however, a script was created to save direct to JPG, which could be modified for other file formats.
/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/using-datasets/td-p/2665594
https://forums.adobe.com/thread/628182
https://forums.adobe.com/message/2773935#2773935
It assumes that the activeDocument has datasets defined and uses the first fieldname in the dataset csv as the savename for the jpg
*/
fileImportDataSets = function(file) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID( "dataSetClass" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putPath( charIDToTypeID( "Usng" ), new File( file ) );
desc.putEnumerated( charIDToTypeID( "Encd" ), stringIDToTypeID( "dataSetEncoding" ), stringIDToTypeID( "dataSetEncodingAuto" ) );
desc.putBoolean( stringIDToTypeID( "eraseAll" ), true );
desc.putBoolean( stringIDToTypeID( "useFirstColumn" ), true );
executeAction( stringIDToTypeID( "importDataSets" ), desc, DialogModes.NO );
}
applyDataSet = function(setName) {
var desc = new ActionDescriptor();
var setRef = new ActionReference();
setRef.putName( stringIDToTypeID( "dataSetClass" ), setName );
desc.putReference( charIDToTypeID( "null" ), setRef );
executeAction( charIDToTypeID( "Aply" ), desc, DialogModes.NO );
}
getDataSetNames = function(csvFileRef) {
_ftn = function(string){
var csvItems = string.split(",");
datasetName = csvItems[0]
return datasetName;
}
csvFileRef.open();
var datasetArray = new Array();
var i = 0;
while (csvString = csvFileRef.readln()) {
if (csvString.length < 2) continue; // Skip empty lines
datasetArray[i] = _ftn(csvString);
i++;
}
csvFileRef.close();
return datasetArray;
}
// jpeg options used for all the saves
var jpgOptns = new JPEGSaveOptions();
jpgOptns.formatOptions = FormatOptions.STANDARDBASELINE;
jpgOptns.embedColorProfile = true;
jpgOptns.matte = MatteType.NONE;
jpgOptns.quality = 8;
//prompt for file
var csvFileRef = File.openDialog("Please select CSV file");
fileImportDataSets(csvFileRef); //inport the CSV file into the template
var datasetNames = getDataSetNames(csvFileRef);// set up the dataset array
//setup a loop for your data set names
for (i=1; i < datasetNames.length; i++) {
applyDataSet(datasetNames[i]);
//edit the file if needed
//save the file. Here I use testItem.contents of layer 'name' as the filename
app.activeDocument.activeLayer = app.activeDocument.artLayers.getByName("name"); // double check that your layer name matches!
jpgSaveFile = new File(csvFileRef.path + "/" + app.activeDocument.activeLayer.textItem.contents + ".jpg");
app.activeDocument.saveAs (jpgSaveFile ,jpgOptns , true, Extension.LOWERCASE);
}//loop to next data set
Copy link to clipboard
Copied
Hi,
Thank you for the script, I am make some progress.
I have created all the variables for visablity inside PS and also created a excel with the complete list of all the
layers variable names so I can populate that with the 10,000 file names I need.
Does the formatting look correct in the excel sheet?
Copy link to clipboard
Copied
For the test do 10 names sample exported to .csv.
Copy link to clipboard
Copied
Hi,
I got the process to work, I was just missing a variable for the file name. I had to add a layer to my PS file and map the variable as text replacment.
My last step is to try the script file above to avoid batch convert.
Copy link to clipboard
Copied
hi,
the script failed to run. It did prompt me to select the csv file but after that it said the variables did not match.
I used the same csv file that I am using for data sets. The import data set, then export data sets and last convert to jpeg works with the csv file.