Skip to main content
Participant
March 30, 2019
Question

Modifying ACR Smart Object Layer

  • March 30, 2019
  • 4 replies
  • 880 views

Hello,

I have a document with a smart object layer that contains an Adobe Camera Raw image. I'm trying to write a script that will automate some ACR adjustments, changes to exposure, white balance, etc. Is it possible to launch ACR on the smart object from a script (equivalent of double clicking the layer in photoshop)? And then modify the ACR raw image settings (exposure, white balance, etc)?

I've tried loading the ScriptingListener and looked at it's output, but I'm not seeing any relevant action executions after I go through the motions.

Thanks in advance for the help,

Dave

This topic has been closed for replies.

4 replies

Participant
April 27, 2019

Thanks guys. I think this approach of modifying the XMP sidecar file and placing as a new layer (linked or embedded) will work for my purposes.

Related question - is there a way to place the raw file as a SmartObject layer along with an explicit XMP sidecar object (XMPMeta) vs implicitly pulling it from disk?  Something like:

function placeRawFile(rawFile, linked)

{

    var desc = new ActionDescriptor();

    desc.putPath(charIDToTypeID('null'), rawFile);

    // Place as linked SmartObject?

    desc.putBoolean(stringIDToTypeID("linked"), linked);

    // Specify ACR XMP data

    desc.putObject( “SOME XMP TYPE ID”,  new XMPMeta( xmpMetaString ));

    // Execute

    executeAction(charIDToTypeID('Plc '), desc, DialogModes.NO);

};

This would avoid me having to modify the XMP file repeatedly and overwriting the original on disk. Instead I could keep it as local data in my script.

Legend
April 29, 2019

In CC2018, you can use the code for a place embedded, obtained using the ScriptListener plugin.

For linked will not work, in CC2018 exactly.

function place(file)

    {

    try {

        var d = new ActionDescriptor();

        d.putPath(stringIDToTypeID("null"), file);

        var d1 = new ActionDescriptor();

        d1.putDouble(charIDToTypeID("Ex12"), -2.5);

        // put here other params to d1 descriptor

        d.putObject(stringIDToTypeID("openAs"), stringIDToTypeID("Adobe Camera Raw"), d1);

        d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));

        var d2 = new ActionDescriptor();

        d2.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("distanceUnit"), 0);

        d2.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("distanceUnit"), 0);

        d.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), d2);

        executeAction(stringIDToTypeID("placeEvent"), d, DialogModes.NO);

        }

    catch (e) { throw(e); }

    }

Legend
April 1, 2019

You can try using "place linked".

Then all you need is to modify the corresponding xmp file.

Geppetto Luis
Legend
March 31, 2019

This should be fine

var desc3 = new ActionDescriptor();

var list1 = new ActionList();

var list2 = new ActionList();

var list3 = new ActionList();

var list4 = new ActionList();

desc3.putString( charIDToTypeID( "CMod" ), "Filter" );

desc3.putEnumerated( charIDToTypeID( "Sett" ), charIDToTypeID( "Sett" ), charIDToTypeID( "Cst " ));

desc3.putEnumerated( charIDToTypeID( "WBal" ), charIDToTypeID( "WBal" ), charIDToTypeID( "Cst " ));

desc3.putInteger( charIDToTypeID( "Temp" ), 8 );

desc3.putInteger( charIDToTypeID( "Tint" ), -7 );

desc3.putBoolean( charIDToTypeID( "CtoG" ), false );

desc3.putInteger( charIDToTypeID( "Strt" ), -11 );

desc3.putInteger( charIDToTypeID( "Shrp" ), 0 );

desc3.putInteger( charIDToTypeID( "LNR " ), 0 );

desc3.putInteger( charIDToTypeID( "CNR " ), 0 );

desc3.putInteger( charIDToTypeID( "VigA" ), 0 );

desc3.putInteger( charIDToTypeID( "BlkB" ), 0 );

desc3.putInteger( charIDToTypeID( "RHue" ), 0 );

desc3.putInteger( charIDToTypeID( "RSat" ), 0 );

desc3.putInteger( charIDToTypeID( "GHue" ), 0 );

desc3.putInteger( charIDToTypeID( "GSat" ), 0 );

desc3.putInteger( charIDToTypeID( "BHue" ), 0 );

desc3.putInteger( charIDToTypeID( "BSat" ), 0 );

desc3.putInteger( charIDToTypeID( "Vibr" ), -3 );

desc3.putInteger( charIDToTypeID( "HA_R" ), 0 );

desc3.putInteger( charIDToTypeID( "HA_O" ), 0 );

desc3.putInteger( charIDToTypeID( "HA_Y" ), 0 );

desc3.putInteger( charIDToTypeID( "HA_G" ), 0 );

desc3.putInteger( charIDToTypeID( "HA_A" ), 0 );

desc3.putInteger( charIDToTypeID( "HA_B" ), 0 );

desc3.putInteger( charIDToTypeID( "HA_P" ), 0 );

desc3.putInteger( charIDToTypeID( "HA_M" ), 0 );

desc3.putInteger( charIDToTypeID( "SA_R" ), 0 );

desc3.putInteger( charIDToTypeID( "SA_O" ), 0 );

desc3.putInteger( charIDToTypeID( "SA_Y" ), 0 );

desc3.putInteger( charIDToTypeID( "SA_G" ), 0 );

desc3.putInteger( charIDToTypeID( "SA_A" ), 0 );

desc3.putInteger( charIDToTypeID( "SA_B" ), 0 );

desc3.putInteger( charIDToTypeID( "SA_P" ), 0 );

desc3.putInteger( charIDToTypeID( "SA_M" ), 0 );

desc3.putInteger( charIDToTypeID( "LA_R" ), 0 );

desc3.putInteger( charIDToTypeID( "LA_O" ), 0 );

desc3.putInteger( charIDToTypeID( "LA_Y" ), 0 );

desc3.putInteger( charIDToTypeID( "LA_G" ), 0 );

desc3.putInteger( charIDToTypeID( "LA_A" ), 0 );

desc3.putInteger( charIDToTypeID( "LA_B" ), 0 );

desc3.putInteger( charIDToTypeID( "LA_P" ), 0 );

desc3.putInteger( charIDToTypeID( "LA_M" ), 0 );

desc3.putInteger( charIDToTypeID( "STSH" ), 0 );

desc3.putInteger( charIDToTypeID( "STSS" ), 0 );

desc3.putInteger( charIDToTypeID( "STHH" ), 0 );

desc3.putInteger( charIDToTypeID( "STHS" ), 0 );

desc3.putInteger( charIDToTypeID( "STB " ), 0 );

desc3.putInteger( charIDToTypeID( "PC_S" ), 0 );

desc3.putInteger( charIDToTypeID( "PC_D" ), 0 );

desc3.putInteger( charIDToTypeID( "PC_L" ), 0 );

desc3.putInteger( charIDToTypeID( "PC_H" ), 0 );

desc3.putInteger( charIDToTypeID( "PC_1" ), 25 );

desc3.putInteger( charIDToTypeID( "PC_2" ), 50 );

desc3.putInteger( charIDToTypeID( "PC_3" ), 75 );

desc3.putDouble( charIDToTypeID( "ShpR" ), 1.000000 );

desc3.putInteger( charIDToTypeID( "ShpD" ), 25 );

desc3.putInteger( charIDToTypeID( "ShpM" ), 0 );

desc3.putInteger( charIDToTypeID( "PCVA" ), 0 );

desc3.putInteger( charIDToTypeID( "GRNA" ), 0 );

desc3.putInteger( charIDToTypeID( "LPEn" ), 0 );

desc3.putInteger( charIDToTypeID( "MDis" ), 0 );

desc3.putInteger( charIDToTypeID( "PerV" ), 0 );

desc3.putInteger( charIDToTypeID( "PerH" ), 0 );

desc3.putDouble( charIDToTypeID( "PerR" ), 0.000000 );

desc3.putInteger( charIDToTypeID( "PerS" ), 100 );

desc3.putInteger( charIDToTypeID( "PerA" ), 0 );

desc3.putInteger( charIDToTypeID( "PerU" ), 0 );

desc3.putDouble( charIDToTypeID( "PerX" ), 0.000000 );

desc3.putDouble( charIDToTypeID( "PerY" ), 0.000000 );

desc3.putInteger( charIDToTypeID( "AuCA" ), 0 );

desc3.putDouble( charIDToTypeID( "Ex12" ), 0.150000 );

desc3.putInteger( charIDToTypeID( "Cr12" ), -5 );

desc3.putInteger( charIDToTypeID( "Hi12" ), 17 );

desc3.putInteger( charIDToTypeID( "Sh12" ), -18 );

desc3.putInteger( charIDToTypeID( "Wh12" ), 0 );

desc3.putInteger( charIDToTypeID( "Bk12" ), 0 );

desc3.putInteger( charIDToTypeID( "Cl12" ), 11 );

desc3.putInteger( charIDToTypeID( "DfPA" ), 0 );

desc3.putInteger( charIDToTypeID( "DPHL" ), 30 );

desc3.putInteger( charIDToTypeID( "DPHH" ), 70 );

desc3.putInteger( charIDToTypeID( "DfGA" ), 0 );

desc3.putInteger( charIDToTypeID( "DPGL" ), 40 );

desc3.putInteger( charIDToTypeID( "DPGH" ), 60 );

desc3.putInteger( charIDToTypeID( "Dhze" ), 15 );

desc3.putInteger( charIDToTypeID( "TMMs" ), 0 );

list1.putInteger( 0 );

list1.putInteger( 0 );

list1.putInteger( 255 );

list1.putInteger( 255 );

desc3.putList( charIDToTypeID( "Crv " ), list1 );

list2.putInteger( 0 );

list2.putInteger( 0 );

list2.putInteger( 255 );

list2.putInteger( 255 );

desc3.putList( charIDToTypeID( "CrvR" ), list2 );

list3.putInteger( 0 );

list3.putInteger( 0 );

list3.putInteger( 255 );

list3.putInteger( 255 );

desc3.putList( charIDToTypeID( "CrvG" ), list3 );

list4.putInteger( 0 );

list4.putInteger( 0 );

list4.putInteger( 255 );

list4.putInteger( 255 );

desc3.putList( charIDToTypeID( "CrvB" ), list4 );

desc3.putString( charIDToTypeID( "CamP" ), "Embedded" );

desc3.putString( charIDToTypeID( "CP_D" ), "54650A341B5B5CCAE8442D0B43A92BCE" );

desc3.putInteger( charIDToTypeID( "PrVe" ), 184549376 );

desc3.putString( charIDToTypeID( "Rtch" ), """""" );

desc3.putString( charIDToTypeID( "REye" ), """""" );

desc3.putString( charIDToTypeID( "LCs " ), """""" );

desc3.putString( charIDToTypeID( "Upri" ), """<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21        ">

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

<rdf:Description rdf:about=""

xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/"

crs:UprightVersion="151388160"

crs:UprightCenterMode="0"

crs:UprightCenterNormX="0.5"

crs:UprightCenterNormY="0.5"

crs:UprightFocalMode="0"

crs:UprightFocalLength35mm="35"

crs:UprightPreview="False"

crs:UprightTransformCount="6"/>

</rdf:RDF>

</x:xmpmeta>

""" );

desc3.putString( charIDToTypeID( "GuUr" ), """<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21">

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

<rdf:Description rdf:about=""

xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/"

crs:UprightFourSegmentsCount="0"/>

</rdf:RDF>

</x:xmpmeta>

""");

desc3.putString( charIDToTypeID( "Look" ), "" );

desc3.putString( charIDToTypeID( "Pset" ), "" );

executeAction( stringIDToTypeID( "Adobe Camera Raw Filter" ), desc3, DialogModes.NO );

JJMack
Community Expert
Community Expert
March 31, 2019

I find that script does not edit(modify) the smart object RAW conversion like open the smart object does. Instead it add a smart Adobe Camera RAW filter to the smart object layer. It filters the Smart Object Layer and if run again will add additional ACR RAW filters  to the smart object layer. If the active layer is not as smart object layer the script destructively filter the active layer content.

JJMack
Chuck Uebele
Community Expert
Community Expert
March 30, 2019

You can't control Camera Raw with a script.

Stephen Marsh
Community Expert
Community Expert
March 31, 2019

Chuck, as ACR adjustments are just metadata entries, would it be possible to add hard coded entries into the open PSB, then save and close? The issue will likely be targeting the PSB, the name will change and so will the index number however that would likely be the best bet. This is easy with ExifTool, but I have never tried it with Photoshop.

JJMack
Community Expert
Community Expert
March 31, 2019

If the layers Object is a RAW File  Photoshop will create a RAW from the layers object and it will open in ACR UI and there will only be an OK of Cancel button in the bottom of ACR UI. Photoshop does not always create PSB work document for smart object.  It depends on what the object is.   Object can be file types that do not open by default in Photoshop they may open in ACR, or in Ai.   Photoshop creates PSB work file when smart object layer are created by converting Photoshop layers into a smart object. There is no actual file on disk for those smart object layers objects.

JJMack