Modify a raw Smart Object on the fly

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

undavide

Modify a raw Smart Object on the fly

Post by undavide »

Hello,
I'd like to modify (via script) the develop settings of a raw file which has been opened as a Smart Object - without calling/opening ACR.
So far I've investigated ActionDescriptor of such a SO layer this way:

Code: Select all// Descriptor 1 (Layer)
var r1 = new ActionReference();
r1.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var d1 = executeActionGet(r1);

// Descriptor keys:
$.writeln("d1.count: " + d1.count); // 29

// Key 27 is smartObject:
$.writeln('Key 27, getKey = '+ app.typeIDToStringID(d1.getKey(27))); // smartOjbect
$.writeln('Key 27, getType = '+ d1.getType (stringIDToTypeID('smartObject'))); // DescValueType.OBJECTTYPE

// Descriptor 2 (put the Smart Object into a Descriptor)
var d2 = d1.getObjectValue(stringIDToTypeID('smartObject'));
for(var i=0;i<d2.count;i++){ //enumerate descriptor's keys: only 2
  $.writeln('Key '+i+' = '+app.typeIDToStringID(d2.getKey(i))+': '+d2.getType(d2.getKey(i)))
}
// Key 0 = placed: DescValueType.ENUMERATEDTYPE
// Key 1 = fileReference: DescValueType.STRINGTYPE

// get the content of Key 0
$.writeln('Key 0 value: ' + app.typeIDToStringID(d2.getEnumerationValue(d2.getKey(0))));
// rasterizeContent

// get the content of Key 1
$.writeln('Key 1 value: ' + d2.getString (d2.getKey(1)));
// IMG2192.dng or whatever

Apparently, the SO descriptor of the layer has only 2 keys, the filename (ok) and a rasterizeContent Enum (which I don't really get, but I will get along with that anyway). This is the bottom of the pit! Am I missing something obvious there?
Thanks in advance as usual!

Davide

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Modify a raw Smart Object on the fly

Post by Mike Hale »

Unless it has changed in CS6 that is it. You have to open the smart object to access any other data.

That second key lets you know if the smart object is a vector or raster object.
undavide

Modify a raw Smart Object on the fly

Post by undavide »

Looks like I've a lot of impossible-to-implement ideas lately!
Thanks for replying Mike.
Does this imply, in your opinion, that one can't access directly nested layers (into a SO) too? Apparently the raw is peculiar, but what about bitmap? I haven't tried, actually, for instance if you've got

Code: Select all- SO
  |- Layer 1
  |- Layer2

would it be possible to, say, switch off Layer 1 via script without opening the SO?
TIA

Davide
Mike Hale

Modify a raw Smart Object on the fly

Post by Mike Hale »

If there is a way I never found it. I spent a lot of time working with smart object when I was developing my SO links panel. There is some info like the layers transform settings that you can not get even by opening the SO.

The descriptor has only two keys. The name key would be more useful if it contained the full path or was a 'ALIASTYPE' data type. The raster type lets you know which app will open the SO. Other than that I don't see a way to get the info if it is not in the descriptor.