how to know smart object image source path

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

robberfree
Posts: 2
Joined: Fri Apr 28, 2017 3:19 pm

how to know smart object image source path

Post by robberfree »

I drag one image from somewhere to ps, and convert to smart object.
can some script to detect the smart object image source path(for example:/Users/robberfree/Desktop/test.jpg)?
thanks a lot.
robberfree
Posts: 2
Joined: Fri Apr 28, 2017 3:19 pm

Re: how to know smart object image source path

Post by robberfree »

if you know how to do it.please give me some tips.
I have read the 《photoshop-cc-javascript-ref-2015》,but not found the according api.
Thanks ahead.
pixxxelschubser
Posts: 26
Joined: Mon Aug 01, 2016 8:59 pm

Re: how to know smart object image source path

Post by pixxxelschubser »

Your crossposting was answered already
https://forums.adobe.com/thread/2310570
wasfiwasfi
Posts: 45
Joined: Fri Nov 04, 2016 8:29 am

Re: how to know smart object image source path

Post by wasfiwasfi »

Correct !
the code provided in the adobe webpage work even on my PS CC.2015
but in order to work you need to convert smart Object to linked (Layer ---> Smart Object ---> Convert to linked).

Code: Select all

try {

var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var soDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObject'));
var thePath = soDesc.getPath(stringIDToTypeID("link"));
alert (thePath);
} catch (e) {};