CameraRAWOpenOptions Needs Update for PV2012

  • 2
  • Problem
  • Updated 6 years ago
Opening files with CameraRAWOpenOptions in Javascript (Extendscript Toolkit) has lost some of its functionality in the upgrade from CS5 to CS6. It looks like the process version has not been updated in the Javasript commands applicable to Adobe Camera RAW/Photoshop (PV2010 worked, PV2012 does not work). The following CameraRAWOpenOptions using Javascript with Photoshop have lost functionality:

CameraRAWOpenOptions.brightness=0; // does not work (0 to 150)

CameraRAWOpenOptions.contrast=0; // does not work (-50 to 100)

CameraRAWOpenOptions.exposure = 0; // does not work (-4.0 to +4.0)

CameraRAWOpenOptions.shadows=0; // (0 to 100) does not work

CameraRAWOpenOptions.whiteBalance=WhiteBalanceType.SHADE; // does not work

I'd particularly like to be able to adjust exposure. Any chance these updates could be made?

I guess one option might be to drop CameraRAWOpenOptions altogether and have users create an XMP file in their scripts instead.

Thanks.

-Bob
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
  • frustrated

Posted 6 years ago

  • 2
Photo of Dorin Nicolaescu-Musteață

Dorin Nicolaescu-Musteață, Champion

  • 703 Posts
  • 38 Reply Likes
Try exposure2012 instead of exposure.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Interesting, exposure works for me but exposure2012 does not.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Hi Bob, I have just tried these options on my system and they work fine.
Tested with:-
Photoshop 13.0 x64
Camera Raw 7.1.0.354
O.S. Windows 7 64bit
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
I wonder if I have something wrong in my script. I am using these same exact versions.
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
I have the following versions, and I'm running the script using ExtendScript.

Photoshop 13.0 x64
Camera Raw 7.1.0.354
O.S. Windows 7 64-bit
Extendscript Toolkit: 3.8.0.12 ExtendScript 4.2.12 ScriptUI 6.1.8

Neither exposure nor exposure2012 works for me.
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
//Here is the entire script I am testing.
var dirNameIn = "/H/pictures/2012_08_11/"; // input directory
var dirNameOut = "/H/Canon/20120811_test/"; // output directory
var firstfile = "7A7A2380.CR2"; // first file to process
var lastfile = "7A7A2382.CR2"; // last file to process

// Array of jpg file names:
var fileListing = new Array();
fileListing = Folder(dirNameIn).getFiles ("7A7A*.CR2");
var NumFiles = fileListing.length;

var nstart = 0;
var nstop = -1;
for (var nfile = 0; nfile < NumFiles; nfile++)
{
if (fileListing[nfile].name == firstfile)
{
nstart = nfile;
}
if (fileListing[nfile].name == lastfile)
{
nstop = nfile + 1;
}
}

// Here is where we will save adjusted images
var SavePath = new Folder(dirNameOut);
SavePath.create();
var FnameSave;

CameraRAWOpenOptions.exposure = +2.00; // does not work (-4.0 to +4.0)
alert(CameraRAWOpenOptions.exposure);
var JPGopts = new JPEGSaveOptions;
JPGopts.quality = 10;

//Perform the loop through the files
for (var nfile = nstart; nfile < nstop; nfile++)
{
app.open(fileListing[nfile], CameraRAWOpenOptions, false);
FnameSave = new File(SavePath+"/"+fileListing[nfile].name);
app.activeDocument.saveAs(FnameSave, JPGopts, false, Extension.UPPERCASE);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
I still have CS5 installed, and it works with Photoshop CS5 (12.0.4 x64), but only starting from the second file in the listing. Something seems to be messed up. Is it possible I need to uninstall CS5?
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
What do you get if you run this?

 

crOpenOptions = new CameraRAWOpenOptions();
crOpenOptions.exposure = 2;
var f = File("/H/pictures/2012_08_11/7A7A2380.CR2");
open(f,crOpenOptions);
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
It opens the image but without any adjustments to exposure (as if crOpenOptions.exposure = 0).

Also, if I try Photoshop CS5 64-bit, it has the same result, but if I open a second image, the exposure adjustment takes effect.
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
I tried in Photoshop CS6 again and thought it was working when I opened a second image, but it was because there was an XMP file associated with the second image (7A7A2381.CR2) that had the Exposure2012=2 in it.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
There does seem to be a problem with your system, a few things you could try are:-
1) Reset your preferences:-
http://forums.adobe.com/thread/375776

2) Create a new User ID

3) De-activate Photoshop, un-install, run the cleaner script and re-install.
http://helpx.adobe.com/creative-suite...

4) Format and do a complete install.

As you mentioned, the xmp can be created/updated by your script, if you didn't want to take drastic action. I could help you with the script if you wanted to take that route.
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
(1), (2), and (3) had no effect, and I don't want to do (4), so I think we'll have to punt on CameraRAWOpenOptions and use XMP instead.

There's probably some setting in the System Registry that is preventing Camera RAW 7 from using the appropriate settings. I'm not sure it would be.

Thanks for you help (so far). The XMP method might be better because you can access more CameraRAW settings that way, or so it seems.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
I am just setting off to the seaside with the grandkids, so it might be tomorrow morning before I can put some thing together.
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
Sounds fun! I am starting off by modifying this script:

http://forums.adobe.com/message/27582...

Some of it is a foreign language to me because it is not clear what is going on in the code (the function placefile, in particular). However, I think it gives me a good starting point.

Thanks.

-Bob
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
We had a fantastic day, and I have had time to put together an example. Hope it helps...



main();
function main(){
var win = new Window( 'dialog', '' );
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
win.orientation='stack';
win.p1= win.add('panel', undefined, undefined, {borderStyle:'black'});
win.g1 = win.p1.add('group');
win.g1.orientation = 'row';
win.title = win.g1.add('statictext',undefined,'Raw Processor');
win.title.alignment='fill';
var g = win.title.graphics;
g.font = ScriptUI.newFont('Georgia','BOLDITALIC',22);
win.g10 =win.p1.add('group');
win.g10.orientation = 'row';
win.g10.alignment='fill';
win.g10.spacing=10;
win.g10.st1 = win.g10.add('statictext',undefined,'Please select source folder');
win.g15 =win.p1.add('group');
win.g15.orientation = 'row';
win.g15.alignment='fill';
win.g15.spacing=10;
win.g15.et1 = win.g15.add('edittext',undefined,'');
win.g15.et1.preferredSize=[350,20];
win.g15.et1.enabled=false;
win.g15.bu1 = win.g15.add('button',undefined,'Browse');
sourceFolder = Folder(Folder.desktop);
win.g15.bu1.onClick=function(){
sourceFolder = Folder.selectDialog('Please select the source folder');
if(sourceFolder !=null){
win.g15.et1.text = decodeURI(sourceFolder.fsName);
}
}
win.g20 =win.p1.add('group');
win.g20.orientation = 'row';
win.g20.alignment='fill';
win.g20.spacing=10;
win.g20.st1 = win.g20.add('statictext',undefined,'Please select output folder');
win.g25 =win.p1.add('group');
win.g25.orientation = 'row';
win.g25.alignment='fill';
win.g25.spacing=10;
win.g25.et1 = win.g25.add('edittext',undefined,'');
win.g25.et1.preferredSize=[350,20];
win.g25.et1.enabled=false;
win.g25.bu1 = win.g25.add('button',undefined,'Browse');
win.g25.bu1.onClick=function(){
outputFolder = Folder.selectDialog('Please select the source folder',sourceFolder);
if(outputFolder !=null){
win.g25.et1.text = decodeURI(outputFolder.fsName);
}
}
win.g200 =win.p1.add('group');
win.g200.orientation = 'row';
win.g200.alignment='bottom';
win.g200.spacing=10;
win.g200.bu1 = win.g200.add('button',undefined,'Process');
win.g200.bu1.preferredSize=[200,35];
win.g200.bu2 = win.g200.add('button',undefined,'Cancel');
win.g200.bu2.preferredSize=[200,35];
win.g200.bu1.onClick=function(){
if(win.g15.et1.text == ''){
alert("No source folder has been selected");
return;
}
if(win.g25.et1.text == ''){
alert("No output folder has been selected");
return;
}
var fileList = sourceFolder.getFiles("*.cr2");
win.close();
for(var z in fileList){
//set metadata
setMetadata(fileList[z]);
//open file
open(fileList[z]);
var Name = fileList[z].name.replace(/
main();
function main(){
var win = new Window( 'dialog', '' );
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
win.orientation='stack';
win.p1= win.add('panel', undefined, undefined, {borderStyle:'black'});
win.g1 = win.p1.add('group');
win.g1.orientation = 'row';
win.title = win.g1.add('statictext',undefined,'Raw Processor');
win.title.alignment='fill';
var g = win.title.graphics;
g.font = ScriptUI.newFont('Georgia','BOLDITALIC',22);
win.g10 =win.p1.add('group');
win.g10.orientation = 'row';
win.g10.alignment='fill';
win.g10.spacing=10;
win.g10.st1 = win.g10.add('statictext',undefined,'Please select source folder');
win.g15 =win.p1.add('group');
win.g15.orientation = 'row';
win.g15.alignment='fill';
win.g15.spacing=10;
win.g15.et1 = win.g15.add('edittext',undefined,'');
win.g15.et1.preferredSize=[350,20];
win.g15.et1.enabled=false;
win.g15.bu1 = win.g15.add('button',undefined,'Browse');
sourceFolder = Folder(Folder.desktop);
win.g15.bu1.onClick=function(){
sourceFolder = Folder.selectDialog('Please select the source folder');
if(sourceFolder !=null){
win.g15.et1.text = decodeURI(sourceFolder.fsName);
}
}
win.g20 =win.p1.add('group');
win.g20.orientation = 'row';
win.g20.alignment='fill';
win.g20.spacing=10;
win.g20.st1 = win.g20.add('statictext',undefined,'Please select output folder');
win.g25 =win.p1.add('group');
win.g25.orientation = 'row';
win.g25.alignment='fill';
win.g25.spacing=10;
win.g25.et1 = win.g25.add('edittext',undefined,'');
win.g25.et1.preferredSize=[350,20];
win.g25.et1.enabled=false;
win.g25.bu1 = win.g25.add('button',undefined,'Browse');
win.g25.bu1.onClick=function(){
outputFolder = Folder.selectDialog('Please select the source folder',sourceFolder);
if(outputFolder !=null){
win.g25.et1.text = decodeURI(outputFolder.fsName);
}
}
win.g200 =win.p1.add('group');
win.g200.orientation = 'row';
win.g200.alignment='bottom';
win.g200.spacing=10;
win.g200.bu1 = win.g200.add('button',undefined,'Process');
win.g200.bu1.preferredSize=[200,35];
win.g200.bu2 = win.g200.add('button',undefined,'Cancel');
win.g200.bu2.preferredSize=[200,35];
win.g200.bu1.onClick=function(){
if(win.g15.et1.text == ''){
alert("No source folder has been selected");
return;
}
if(win.g25.et1.text == ''){
alert("No output folder has been selected");
return;
}
var fileList = sourceFolder.getFiles("*.cr2");
win.close();
for(var z in fileList){
//set metadata
setMetadata(fileList[z]);
//open file
open(fileList[z]);
var Name = fileList[z].name.replace(/\.[^\.]+$/, '');
var saveFile = File(outputFolder + "/" + Name + ".jpg");
//save as jpeg
SaveJPEG(saveFile,10);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
win.center();
win.show();
}
function setMetadata(Rawfile){
var Name = File(Rawfile).name.replace(/\.[^\.]+$/, '');
var file = File(Rawfile.path + "/" + Name + ".xmp");
try{
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
if(file.exists){
file.open('r');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var xmpStr = file.read();
file.close();
}else{ var xmpStr='';}
var xmp = new XMPMeta( xmpStr );
//set values as required
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Exposure", 0.2 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Brightness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Brightness", 30 );
/*************** etc
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Saturation");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Saturation", 8 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Shadows");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Shadows", 1 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Sharpness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Sharpness", 25 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Clarity");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Clarity", 15 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "HighlightRecovery");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "HighlightRecovery", 11 );
*/
file.open('w');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.write( xmp.serialize() );
file.close();
}catch(e){alert(e+"-"+e.line);}
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}

#46;[^
main();
function main(){
var win = new Window( 'dialog', '' );
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
win.orientation='stack';
win.p1= win.add('panel', undefined, undefined, {borderStyle:'black'});
win.g1 = win.p1.add('group');
win.g1.orientation = 'row';
win.title = win.g1.add('statictext',undefined,'Raw Processor');
win.title.alignment='fill';
var g = win.title.graphics;
g.font = ScriptUI.newFont('Georgia','BOLDITALIC',22);
win.g10 =win.p1.add('group');
win.g10.orientation = 'row';
win.g10.alignment='fill';
win.g10.spacing=10;
win.g10.st1 = win.g10.add('statictext',undefined,'Please select source folder');
win.g15 =win.p1.add('group');
win.g15.orientation = 'row';
win.g15.alignment='fill';
win.g15.spacing=10;
win.g15.et1 = win.g15.add('edittext',undefined,'');
win.g15.et1.preferredSize=[350,20];
win.g15.et1.enabled=false;
win.g15.bu1 = win.g15.add('button',undefined,'Browse');
sourceFolder = Folder(Folder.desktop);
win.g15.bu1.onClick=function(){
sourceFolder = Folder.selectDialog('Please select the source folder');
if(sourceFolder !=null){
win.g15.et1.text = decodeURI(sourceFolder.fsName);
}
}
win.g20 =win.p1.add('group');
win.g20.orientation = 'row';
win.g20.alignment='fill';
win.g20.spacing=10;
win.g20.st1 = win.g20.add('statictext',undefined,'Please select output folder');
win.g25 =win.p1.add('group');
win.g25.orientation = 'row';
win.g25.alignment='fill';
win.g25.spacing=10;
win.g25.et1 = win.g25.add('edittext',undefined,'');
win.g25.et1.preferredSize=[350,20];
win.g25.et1.enabled=false;
win.g25.bu1 = win.g25.add('button',undefined,'Browse');
win.g25.bu1.onClick=function(){
outputFolder = Folder.selectDialog('Please select the source folder',sourceFolder);
if(outputFolder !=null){
win.g25.et1.text = decodeURI(outputFolder.fsName);
}
}
win.g200 =win.p1.add('group');
win.g200.orientation = 'row';
win.g200.alignment='bottom';
win.g200.spacing=10;
win.g200.bu1 = win.g200.add('button',undefined,'Process');
win.g200.bu1.preferredSize=[200,35];
win.g200.bu2 = win.g200.add('button',undefined,'Cancel');
win.g200.bu2.preferredSize=[200,35];
win.g200.bu1.onClick=function(){
if(win.g15.et1.text == ''){
alert("No source folder has been selected");
return;
}
if(win.g25.et1.text == ''){
alert("No output folder has been selected");
return;
}
var fileList = sourceFolder.getFiles("*.cr2");
win.close();
for(var z in fileList){
//set metadata
setMetadata(fileList[z]);
//open file
open(fileList[z]);
var Name = fileList[z].name.replace(/\.[^\.]+$/, '');
var saveFile = File(outputFolder + "/" + Name + ".jpg");
//save as jpeg
SaveJPEG(saveFile,10);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
win.center();
win.show();
}
function setMetadata(Rawfile){
var Name = File(Rawfile).name.replace(/\.[^\.]+$/, '');
var file = File(Rawfile.path + "/" + Name + ".xmp");
try{
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
if(file.exists){
file.open('r');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var xmpStr = file.read();
file.close();
}else{ var xmpStr='';}
var xmp = new XMPMeta( xmpStr );
//set values as required
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Exposure", 0.2 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Brightness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Brightness", 30 );
/*************** etc
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Saturation");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Saturation", 8 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Shadows");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Shadows", 1 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Sharpness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Sharpness", 25 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Clarity");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Clarity", 15 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "HighlightRecovery");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "HighlightRecovery", 11 );
*/
file.open('w');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.write( xmp.serialize() );
file.close();
}catch(e){alert(e+"-"+e.line);}
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}

#46;]+$/, '');
var saveFile = File(outputFolder + "/" + Name + ".jpg");
//save as jpeg
SaveJPEG(saveFile,10);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
win.center();
win.show();
}
function setMetadata(Rawfile){
var Name = File(Rawfile).name.replace(/
main();
function main(){
var win = new Window( 'dialog', '' );
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
win.orientation='stack';
win.p1= win.add('panel', undefined, undefined, {borderStyle:'black'});
win.g1 = win.p1.add('group');
win.g1.orientation = 'row';
win.title = win.g1.add('statictext',undefined,'Raw Processor');
win.title.alignment='fill';
var g = win.title.graphics;
g.font = ScriptUI.newFont('Georgia','BOLDITALIC',22);
win.g10 =win.p1.add('group');
win.g10.orientation = 'row';
win.g10.alignment='fill';
win.g10.spacing=10;
win.g10.st1 = win.g10.add('statictext',undefined,'Please select source folder');
win.g15 =win.p1.add('group');
win.g15.orientation = 'row';
win.g15.alignment='fill';
win.g15.spacing=10;
win.g15.et1 = win.g15.add('edittext',undefined,'');
win.g15.et1.preferredSize=[350,20];
win.g15.et1.enabled=false;
win.g15.bu1 = win.g15.add('button',undefined,'Browse');
sourceFolder = Folder(Folder.desktop);
win.g15.bu1.onClick=function(){
sourceFolder = Folder.selectDialog('Please select the source folder');
if(sourceFolder !=null){
win.g15.et1.text = decodeURI(sourceFolder.fsName);
}
}
win.g20 =win.p1.add('group');
win.g20.orientation = 'row';
win.g20.alignment='fill';
win.g20.spacing=10;
win.g20.st1 = win.g20.add('statictext',undefined,'Please select output folder');
win.g25 =win.p1.add('group');
win.g25.orientation = 'row';
win.g25.alignment='fill';
win.g25.spacing=10;
win.g25.et1 = win.g25.add('edittext',undefined,'');
win.g25.et1.preferredSize=[350,20];
win.g25.et1.enabled=false;
win.g25.bu1 = win.g25.add('button',undefined,'Browse');
win.g25.bu1.onClick=function(){
outputFolder = Folder.selectDialog('Please select the source folder',sourceFolder);
if(outputFolder !=null){
win.g25.et1.text = decodeURI(outputFolder.fsName);
}
}
win.g200 =win.p1.add('group');
win.g200.orientation = 'row';
win.g200.alignment='bottom';
win.g200.spacing=10;
win.g200.bu1 = win.g200.add('button',undefined,'Process');
win.g200.bu1.preferredSize=[200,35];
win.g200.bu2 = win.g200.add('button',undefined,'Cancel');
win.g200.bu2.preferredSize=[200,35];
win.g200.bu1.onClick=function(){
if(win.g15.et1.text == ''){
alert("No source folder has been selected");
return;
}
if(win.g25.et1.text == ''){
alert("No output folder has been selected");
return;
}
var fileList = sourceFolder.getFiles("*.cr2");
win.close();
for(var z in fileList){
//set metadata
setMetadata(fileList[z]);
//open file
open(fileList[z]);
var Name = fileList[z].name.replace(/\.[^\.]+$/, '');
var saveFile = File(outputFolder + "/" + Name + ".jpg");
//save as jpeg
SaveJPEG(saveFile,10);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
win.center();
win.show();
}
function setMetadata(Rawfile){
var Name = File(Rawfile).name.replace(/\.[^\.]+$/, '');
var file = File(Rawfile.path + "/" + Name + ".xmp");
try{
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
if(file.exists){
file.open('r');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var xmpStr = file.read();
file.close();
}else{ var xmpStr='';}
var xmp = new XMPMeta( xmpStr );
//set values as required
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Exposure", 0.2 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Brightness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Brightness", 30 );
/*************** etc
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Saturation");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Saturation", 8 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Shadows");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Shadows", 1 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Sharpness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Sharpness", 25 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Clarity");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Clarity", 15 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "HighlightRecovery");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "HighlightRecovery", 11 );
*/
file.open('w');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.write( xmp.serialize() );
file.close();
}catch(e){alert(e+"-"+e.line);}
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}

#46;[^
main();
function main(){
var win = new Window( 'dialog', '' );
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
win.orientation='stack';
win.p1= win.add('panel', undefined, undefined, {borderStyle:'black'});
win.g1 = win.p1.add('group');
win.g1.orientation = 'row';
win.title = win.g1.add('statictext',undefined,'Raw Processor');
win.title.alignment='fill';
var g = win.title.graphics;
g.font = ScriptUI.newFont('Georgia','BOLDITALIC',22);
win.g10 =win.p1.add('group');
win.g10.orientation = 'row';
win.g10.alignment='fill';
win.g10.spacing=10;
win.g10.st1 = win.g10.add('statictext',undefined,'Please select source folder');
win.g15 =win.p1.add('group');
win.g15.orientation = 'row';
win.g15.alignment='fill';
win.g15.spacing=10;
win.g15.et1 = win.g15.add('edittext',undefined,'');
win.g15.et1.preferredSize=[350,20];
win.g15.et1.enabled=false;
win.g15.bu1 = win.g15.add('button',undefined,'Browse');
sourceFolder = Folder(Folder.desktop);
win.g15.bu1.onClick=function(){
sourceFolder = Folder.selectDialog('Please select the source folder');
if(sourceFolder !=null){
win.g15.et1.text = decodeURI(sourceFolder.fsName);
}
}
win.g20 =win.p1.add('group');
win.g20.orientation = 'row';
win.g20.alignment='fill';
win.g20.spacing=10;
win.g20.st1 = win.g20.add('statictext',undefined,'Please select output folder');
win.g25 =win.p1.add('group');
win.g25.orientation = 'row';
win.g25.alignment='fill';
win.g25.spacing=10;
win.g25.et1 = win.g25.add('edittext',undefined,'');
win.g25.et1.preferredSize=[350,20];
win.g25.et1.enabled=false;
win.g25.bu1 = win.g25.add('button',undefined,'Browse');
win.g25.bu1.onClick=function(){
outputFolder = Folder.selectDialog('Please select the source folder',sourceFolder);
if(outputFolder !=null){
win.g25.et1.text = decodeURI(outputFolder.fsName);
}
}
win.g200 =win.p1.add('group');
win.g200.orientation = 'row';
win.g200.alignment='bottom';
win.g200.spacing=10;
win.g200.bu1 = win.g200.add('button',undefined,'Process');
win.g200.bu1.preferredSize=[200,35];
win.g200.bu2 = win.g200.add('button',undefined,'Cancel');
win.g200.bu2.preferredSize=[200,35];
win.g200.bu1.onClick=function(){
if(win.g15.et1.text == ''){
alert("No source folder has been selected");
return;
}
if(win.g25.et1.text == ''){
alert("No output folder has been selected");
return;
}
var fileList = sourceFolder.getFiles("*.cr2");
win.close();
for(var z in fileList){
//set metadata
setMetadata(fileList[z]);
//open file
open(fileList[z]);
var Name = fileList[z].name.replace(/\.[^\.]+$/, '');
var saveFile = File(outputFolder + "/" + Name + ".jpg");
//save as jpeg
SaveJPEG(saveFile,10);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
win.center();
win.show();
}
function setMetadata(Rawfile){
var Name = File(Rawfile).name.replace(/\.[^\.]+$/, '');
var file = File(Rawfile.path + "/" + Name + ".xmp");
try{
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
if(file.exists){
file.open('r');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var xmpStr = file.read();
file.close();
}else{ var xmpStr='';}
var xmp = new XMPMeta( xmpStr );
//set values as required
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Exposure", 0.2 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Brightness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Brightness", 30 );
/*************** etc
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Saturation");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Saturation", 8 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Shadows");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Shadows", 1 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Sharpness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Sharpness", 25 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Clarity");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Clarity", 15 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "HighlightRecovery");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "HighlightRecovery", 11 );
*/
file.open('w');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.write( xmp.serialize() );
file.close();
}catch(e){alert(e+"-"+e.line);}
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}

#46;]+$/, '');
var file = File(Rawfile.path + "/" + Name + ".xmp");
try{
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
if(file.exists){
file.open('r');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.open("r", "TEXT", "????");
var xmpStr = file.read();
file.close();
}else{ var xmpStr='';}
var xmp = new XMPMeta( xmpStr );
//set values as required
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Exposure");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Exposure", 0.2 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Brightness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Brightness", 30 );
/*************** etc
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Saturation");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Saturation", 8 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Shadows");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Shadows", 1 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Sharpness");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Sharpness", 25 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "Clarity");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "Clarity", 15 );
xmp.deleteProperty(XMPConst.NS_CAMERA_RAW, "HighlightRecovery");
xmp.setProperty( XMPConst.NS_CAMERA_RAW, "HighlightRecovery", 11 );
*/
file.open('w');
file.encoding = "UTF8";
file.lineFeed = "unix";
file.write( xmp.serialize() );
file.close();
}catch(e){alert(e+"-"+e.line);}
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}

Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
Paul,

A belated thanks for your help here (I was away over part of the weekend, have been working at my regular job this week, and I'm finally able to get to this stuff again this evening).

I will take a look at the script. There is a lot there, so it will take some time to digest it, modify it, and experiment with it a bit. Certainly, it teaches me a lot about how to work with XMP files, so it gives me what I need for now.

FYI, if you're curious about the things I'm trying to do... I have been putting together time lapses from images I have shot from my Canon 5d.

https://www.youtube.com/user/tornadobob1/

A lot of times, I make changes to the camera settings when I'm out taking images, due to changing lighting (sunset, sudden changes in the intensity of auroras, etc.) and need to compensate for those changes when I put the time lapses together. Working with XMP files gives me more options for making changes to the RAW images, so I'm hoping to become proficient with that. The CameraRAWOpenOptions settings not working might not be such a bad thing.

Again, thanks.

-Bob
Photo of Robert Conzemius

Robert Conzemius

  • 11 Posts
  • 0 Reply Likes
Something gets goofed up when copying script to this page. I had trouble getting my original script copied correctly last week, and I noticed it duplicated a lot of your script several times, but I think I've gotten the duplicate lines removed and am testing the script now.
Photo of Paul Riggott

Paul Riggott

  • 359 Posts
  • 143 Reply Likes
Yes, it would be nice if you could attach zip files here.
I have put the script here if you are having probems...
http://www.scriptsrus.talktalk.net/do...