Copy link to clipboard
Copied
i have psd file in that one of the layer i have attached placed which is .png file
how to get those details
here in the above screenshot first layer contains the placed layer , when i double click one png file will open.
so how get that png file details, like width,height,name and image data.
and that placed layer details where they will save meaning in which block they will save the placed layer data.
thank you
Copy link to clipboard
Copied
Continued from this post:
Copy link to clipboard
Copied
To edit/open a Photoshop-compatible raster Smart Object layer/file (assumed as placed or embedded):
if (app.activeDocument.activeLayer.kind == LayerKind.SMARTOBJECT) {
app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
}
You can then use the document class properties:
https://theiviaxx.github.io/photoshop-docs/Photoshop/Document.html
alert("Doc width: " + app.activeDocument.width);
// or
alert("Doc width: " + app.activeDocument.width.value);
// or
var savedRuler = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
alert("Doc height: " + app.activeDocument.height.value);
app.preferences.rulerUnits = savedRuler;
// or
alert("Doc height: " + app.activeDocument.height.as('px'));
I believe that the code from @c.pfaffenbichler directly retrieved the properties of the SO without opening it.
Copy link to clipboard
Copied
Document properties code example:
Layer properties code example:
https://gist.github.com/MarshySwamp/ef345ef3dec60a843465347ee6fcae2f
Copy link to clipboard
Copied
»here in the above screenshot first layer contains the placed layer , when i double click one png file will open.
so how get that png file details, like width,height,name and image data.«
What do you mean by »image data«?
// based on code by michael l hale;
// 2024, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var soDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObject'));
var soMoreDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObjectMore'));
checkDesc2 (soMoreDesc.getObjectValue(stringIDToTypeID("size")));
};
////// based on code by michael l hale //////
function checkDesc2 (theDesc) {
var c = theDesc.count;
var str = '';
for(var i=0;i<c;i++){ //enumerate descriptor's keys
str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
};
alert("desc\n\n"+str);
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.ALIASTYPE:
return theDesc.getPath(theDesc.getKey(theNumber));
break;
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default:
break;
};
};
Copy link to clipboard
Copied
thanks @c.pfaffenbichler
Copy link to clipboard
Copied
As for the name:
// based on code by michael l hale;
// 2024, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var soDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObject'));
alert (soDesc.getString(stringIDToTypeID('fileReference')));
};
Copy link to clipboard
Copied
@c.pfaffenbichler thanks i'll check this.
in the above screenshot the placed layer details where it is saved.
for example in th second screenshot i have provided . when i double click one jpeg file will open.and that jpeg file contains path.
the third image is the path that jpeg file contains.
how to retrieve this path point and in the photoshop file format structure where that placed layer path point details are stored.
Copy link to clipboard
Copied
I doubt that this is possible with ESTK Scripting without opening the Smart Object.
Copy link to clipboard
Copied
hi @c.pfaffenbichler in photoshop file format in which section that placed layer data is saved.
Copy link to clipboard
Copied
No idea.
If you want to read the file data itself make sure the file is actually saved while »plain« ESTK Scripting will reflect the changes in open but unsaved images.
Copy link to clipboard
Copied
Your “Photoshop file structure" screenshot would appear to be something related to SDK or perhaps another non-scripting resource. I previously linked to one source of documentation on scripting DOM for an open document.
Copy link to clipboard
Copied
@Stephen_A_Marsh yes i just want know about that where exactly the placed layer path point details are saved according to that file structure
Copy link to clipboard
Copied
What are you planning on doing, a binary read of the PSD?
https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
https://www.fileformat.info/format/psd/egff.htm
Copy link to clipboard
Copied
yes @Stephen_A_Marsh