I use the script below which turns every group into a JPEG. It works perfectly. I select a PNG design to go into a smart layer in Photoshop which then sits on an image of a product.
My question is, I have 3000 designs. Is there a way to make a large selection of PNG files that I want importing into Photoshop, to put into the smart layer I have arranged, close and save the smart layer so it is then applied to each product, and then using this script to save each group as a JPEG?
Many thanks for any help!
| #target photoshop | |
| function main(){ | |
| if(!documents.length) return; | |
| var doc = activeDocument; | |
| var oldPath = activeDocument.path; | |
| for(var a=0;a<doc.layerSets.length;a++){ | |
| activeDocument.activeLayer = |
activeDocument.layers.getByName(doc.layerSets[a].name);
| dupLayers(); | |
| activeDocument.mergeVisibleLayers(); | |
| activeDocument.trim |
(TrimType.TRANSPARENT,true,true,true,true);
| var saveFile= File(oldPath +"/NAMEHERE |
-"+doc.layerSets[a].name +".jpg");
| saveJPG(saveFile,10); | |
| app.activeDocument.close |
(SaveOptions.DONOTSAVECHANGES);
| } | |
| } | |
| main(); | |
| function dupLayers() { | |
| var desc143 = new ActionDescriptor(); | |
| var ref73 = new ActionReference(); | |
| ref73.putClass( charIDToTypeID('Dcmn') ); | |
| desc143.putReference( charIDToTypeID('null'), ref73 ); | |
| desc143.putString( charIDToTypeID('Nm '), |
activeDocument.activeLayer.name );
| var ref74 = new ActionReference(); | |
| ref74.putEnumerated( charIDToTypeID('Lyr '), |
charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
| desc143.putReference( charIDToTypeID('Usng'), ref74 ); | |
| executeAction( charIDToTypeID('Mk '), desc143, |
DialogModes.NO );
| } | |
| function saveJPG(saveFile, jpegQuality) { | |
| app.activeDocument.flatten(); | |
| jpgSaveOptions = new JPEGSaveOptions(); | |
| jpgSaveOptions.embedColorProfile = true; | |
| jpgSaveOptions.formatOptions = |
FormatOptions.STANDARDBASELINE;
| jpgSaveOptions.matte = MatteType.NONE; | |
| jpgSaveOptions.quality = jpegQuality; //1-12 | |
| activeDocument.saveAs(saveFile, jpgSaveOptions, |
true,Extension.LOWERCASE);
| } |