• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Save to exr format with jsx script

New Here ,
Mar 31, 2023 Mar 31, 2023

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

 

TOPICS
Actions and scripting

Views

345

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Mar 31, 2023 Mar 31, 2023

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 );
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 04, 2023 Apr 04, 2023

Copy link to clipboard

Copied

LATEST

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines