Copy link to clipboard
Copied
Hi,
Is there a way to save a document as Exr with a jsx script ?
My source image is a dng. With the UI, I need to change the Image > Mode to 32 bits/Channels
Once I've set the 32 bits/Channels, I have the OpenEXR option in save as type.
I'd like to be able to do that in a jsx script.
Regards,
Louise
Copy link to clipboard
Copied
@Louise2504533747tw – Do you know how to script? Why a script over an action?
Some context on how the script would be used would help.
Here is an example, not knowing the context/details it may or may not suit your requirements:
/*
Save As OpenEXR.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-to-exr-format-with-jsx-script/td-p/13695828
v1.0, 1st April 2023, Stephen Marsh
*/
#target photoshop
activeDocument.bitsPerChannel = BitsPerChannelType.THIRTYTWO;
var docName = activeDocument.name.replace(/\.[^\.]+$/, '');
try {
var savePath = activeDocument.path;
} catch (e) {
var savePath = Folder.selectDialog('The doc has never been saved, please select the save folder:');
}
var saveFileEXR = new File(savePath + '/' + docName + ".exr");
if (saveFileEXR.exists) {
// true = 'No' as default active button
if (!confirm("File exists, overwrite: Yes or No?", true))
// throw alert("Script cancelled!");
throw null;
}
saveEXR(0, 1, saveFileEXR, false, true);
function saveEXR(compression, alphaChannelOptions, savePath, asCopy, lowerCase) {
// Compression: 0 = None | 1 = RLE | 2 = Zlib | 4 = Wavelet | 5 = PIXR24 on 32 bit
function c2t(s) {
return app.charIDToTypeID(s);
}
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
descriptor2.putInteger( s2t( "bitDepth" ), 32 );
descriptor2.putInteger( s2t("compression"), compression );
descriptor2.putInteger( s2t( "alphaChannelOptions" ), alphaChannelOptions );
descriptor.putObject( s2t( "as" ), c2t( "EXRf" ), descriptor2 );
descriptor.putPath( s2t( "in" ), savePath );
descriptor.putBoolean( s2t( "copy" ), asCopy );
descriptor.putBoolean( s2t( "lowerCase" ), lowerCase );
descriptor.putEnumerated( s2t( "saveStage" ), s2t( "saveStageType" ), s2t( "saveSucceeded" ));
executeAction( s2t( "save" ), descriptor, DialogModes.NO );
}
Copy link to clipboard
Copied
Hi Stephen,
It's exactly what I needed.
I can export all dng images to exr from a source folder with a command line.
And Yes I know how to script but mainly in python and I don't know photoshop api.
Thanks a lot,
Louise