Copy link to clipboard
Copied
Is it possible to manipulate the Camera Raw settings with a javascript? I've been looking for info on this and have had no luck finding any.
What I'm doing is multiple conversions from a single RAW file set at different exposures, brightnesses, sharpnesses, etc.
Here are the basic steps:
1. Open RAW file in ACR.
2. Adjust for a baseline image.
3. Open image as an object in Photoshop.
4. Duplicate that object layer and run "edit settings" on this new layer.
5. Make adjustments ***
6. Click OK to apply new settings to this layer.
7. Repeat steps 4-6 on original layer as many times as needed.
I got everything working as I want, but I'd like to be able to automate step 5 for certain file types so that it will set some of the settings for me without going through the dialog to do this. The settings I'd really like to be able to adjust this way are exposure and brightness and if possible, I'd like to set them in relation to the original layer's settings for those parameters.
Here is what I had in mind. Note the document is the same size as the raw file. This will place 5 copies of the raw file in the activeDocument, each with a different exposure.
...var rawFile = new File( "~/Desktop/DSC_5396.NEF" );
var xmpFile = new File( "~/Desktop/DSC_5396.xmp" );
var exposures = ['-2.0','-1.0','0.0','1.0','2.0'];
for(var e=0;e<exposures.length;e++){
setExposure( xmpFile, exposures);
placeFile( rawFile );
}
function setExposure( file, exp ){
file.open('r');
file.encodin
Copy link to clipboard
Copied
Camera Raw settings are stored as XMP data in the file ( in the case of DNG,
jpg, or tiff files) or in XMP side-car files. In either case, you can modify
them. You probably need to do an Export, Edit XMP, Reload sequence in your
situation. You can edit the XMP data either using the XMP library (described
in the JS Tools Guide) or using the metadata interface in Bridge.
Copy link to clipboard
Copied
So then the easiest way would be to just open the file normally instead of as an object, then run the script which will update the sidecar file, then open another instance of the document and repeat this process for the various settings I would need. Then I'd need to copy each open document back onto the layer stack in the original.
Does CS5 have scripting support for the ACR dialog? ![]()
Thanks, xbytor. I think that based on my script writing skill level it might be easiest to just continue on as I'm doing.
Or wait, If I open as an object from ACR then duplicate the layer, then update the .xml file, then edit settings, would this reflect the changes made? If so, that might actually be simple enough for me to do and if I suppress dialogs it would basically be a transparent process.
Something to work on.
Copy link to clipboard
Copied
What I would do is edit the settings, place as smart object, edit the settings again, and place again. Repeating as many times as you need. You would end up with the same results, a document with several layers containing the same image as separate smart objects.
From reading the scripting guide, there is nothing added to allow CS5 to edit inside ACR. So even with that version the easiest way would be to edit the metadata.
What version of Photoshop are you using now?
Copy link to clipboard
Copied
I'm using CS4 now.
I'm playing around with this and it seems that when a file is opened from ACR as an Object into Photoshop, the original sidecar file is no longer used. When I change the values in the original sidecar file and edit settings on the layer, nothing has changed. When I change the settings in ACR after choosing edit settings and accept, the original sidecar file is not updated to reflect the changes.
I'm currently doing a search on my hard drive to see if there is another sidecar file created for this. I hope it isn't kept in memory or scratch space.
Copy link to clipboard
Copied
>
I'm playing around with this and it seems that when a file is opened from
ACR as an Object into Photoshop, the original sidecar file is no longer
used. When I change the values in the original sidecar file and edit
settings on the layer, nothing has changed.
Once you open a raw file in PS (via ACR or not), the image is rendered. The
Camera Raw XMP metadata no longer has any meaning except as a record of the
processing that was applied.
There is no scripting of the ACR dialog, unfortunately.
-X
Copy link to clipboard
Copied
Even if you open as an object from ACR? According to the help file: "Press Shift while clicking Open Image to open the image as a Smart Object in Photoshop. At any time, you can double-click the Smart Object layer that contains the raw file to adjust the Camera Raw settings." This tells me that the Smart Object is still actually the RAW file itself and has not yet been rendered. But I really don't know for sure.
Example: I open up a file as object from ACR (Hold shift while clicking "Open Object" button). If I make a copy of that layer (drag down to create new layer) then right-click on the layer name and choose "Edit Contents" it reopens the ACR dialog. I can make changes to this and whatever changes I make are processed on all normal copies of this layer. I can make as many changes as I want and each time I reopen the ACR dialog in this manner, the last settings that I used on that layer are active regardless of what the original sidecar file holds.
If I right-click on the layer and choose "New Smart Object via Copy", that creates a new layer also, but the "Edit Contents" settings in ACR are independent of the layer it was copied from. I can then change this layer as much as I want and those settings are preserved and changeable until I rasterize the layer or convert to Smart Object. In this manner, I can create as many independent Object Layers that can be reopened in ACR to have new settings applied.
I'm trying to find where those settings are kept. They are not in the original sidecar file nor any other file I can find with a search. This leaves me with my first option of opening up the same RAW file multiple times from disk after altering the sidecar file for the changes I want then copying all the layers into one document.
Copy link to clipboard
Copied
Here is what I had in mind. Note the document is the same size as the raw file. This will place 5 copies of the raw file in the activeDocument, each with a different exposure.
var rawFile = new File( "~/Desktop/DSC_5396.NEF" );
var xmpFile = new File( "~/Desktop/DSC_5396.xmp" );
var exposures = ['-2.0','-1.0','0.0','1.0','2.0'];
for(var e=0;e<exposures.length;e++){
setExposure( xmpFile, exposures);
placeFile( rawFile );
}
function setExposure( file, exp ){
file.open('r');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var xmpStr = file.read();
file.close();
loadXMPLibrary();
var xmp = new XMPMeta( xmpStr );
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Exposure", exp );
file.open('w');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.write( xmp.serialize() );
file.close();
};
function placeFile( file) {
var desc = new ActionDescriptor();
desc.putPath( charIDToTypeID('null'), file );
desc.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa') );
var offsetDesc = new ActionDescriptor();
offsetDesc.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), 0.000000 );
offsetDesc.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), 0.000000 );
desc.putObject( charIDToTypeID('Ofst'), charIDToTypeID('Ofst'), offsetDesc );
executeAction( charIDToTypeID('Plc '), desc, DialogModes.NO );
};
function loadXMPLibrary(){
if ( !ExternalObject.AdobeXMPScript ){
try{
ExternalObject.AdobeXMPScript = new ExternalObject
('lib:AdobeXMPScript');
}catch (e){
alert( ErrStrs.XMPLIB );
return false;
}
}
return true;
};
function unloadXMPLibrary(){
if( ExternalObject.AdobeXMPScript ) {
try{
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
}catch (e){
alert( ErrStrs.XMPLIB );
}
}
};
Copy link to clipboard
Copied
This looks like it might be the way to go. I can integrate this into my other scripts/actions easily enough, too.
Thanks, Mike. ![]()
Copy link to clipboard
Copied
is the above script for CS5 only?
when i try to run in CS4 (With ACR 5.2) i get the following error for line 32 or "executeAction( charIDToTypeID('Plc '), desc, DialogModes.NO );"
"general photoshop error occurred. This functionality may not be available in this version of Photoshop."
Also can anyone point me in the direction of the best source of info on scripting & ACR? is this included in the Photoshop SDK?
Thanks!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more