Copy link to clipboard
Copied
Hi
I wish export one selected layer as jpeg (qty 12), and keep the layer name as a new file name.
I wich also this file was registered in a specific folder contained in the original document folder
"folder X" for example.
If this folder X exist so don't need to create it.
Thanks a lot for helping
Try this.
...#target photoshop;
if (app.documents.length > 0) {
var DocPath = app.activeDocument.path;
dupLayers();
var idFltI = charIDToTypeID( "FltI" );
executeAction( idFltI, undefined, DialogModes.NO );
var DupdocName = app.activeDocument.name;
SaveJPEG();
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
function SaveJPEG(){
var myfolder = new Folder(DocPath+ "/"+"folder X");
if (!myfolder.exists) {myfolder.create();
};
jpgFile = new File(myfolder+ "/"+DupdocName+".jpg");
jpgSaveOptions = new JPEGS
Copy link to clipboard
Copied
With your script you should be able to dupe the selected layer to a new document with any name you want. Then save that new document into any folder you want. A script can test for the existence of a folder and create it if is does not exist. To can save a jpeg at any quality you want you will not see any difference between quality 12 and quality 10 image with your eyes the big difference you well see is in file size. The quality 10 file will be much smaller then the quality 12 file. If you can not find a DOM method to do it all you need to, You will need to through in some action manager code. After you save the new document close the document so Photoshop will switch back to the original document.
Copy link to clipboard
Copied
Hi JJMack,
The main pb for me is to give to the new doc name the name of THE layer i want to duplicate.
I am not almost close...
Copy link to clipboard
Copied
As I wrote if you can not find a way to do something you want to do with DOM code you can have the Scriplistener Plug-in record some Action Manager code you can create a JavaScript function with to do what you want to do. Installs the plug-in and have it record Duplicating a layer into a new document with the document name you want and the layer name you want. Get the code recorder and replace the hard coded document name and the hard coded layer name was vat you pass the function you create. Name the document with the layer name, name the layer with the layer name.
Copy link to clipboard
Copied
Try this.
#target photoshop;
if (app.documents.length > 0) {
var DocPath = app.activeDocument.path;
dupLayers();
var idFltI = charIDToTypeID( "FltI" );
executeAction( idFltI, undefined, DialogModes.NO );
var DupdocName = app.activeDocument.name;
SaveJPEG();
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
function SaveJPEG(){
var myfolder = new Folder(DocPath+ "/"+"folder X");
if (!myfolder.exists) {myfolder.create();
};
jpgFile = new File(myfolder+ "/"+DupdocName+".jpg");
jpgSaveOptions = new JPEGSaveOptions()
jpgSaveOptions.embedColorProfile = true
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;
app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true,Extension.LOWERCASE);
}
function dupLayers() { //code by SuperMerlin
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 );
};
Hth.