• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to get the smart object image source path?

New Here ,
May 01, 2017 May 01, 2017

Copy link to clipboard

Copied

i drag a image from somewhere(for example:/Users/robberfree/Desktop/test.jpg) to PS,

then convert it to smart object.

can i use script to get the smart object image original source path.

i search the 《photoshop-cc-javascript-ref-2015》document but don't found what i want.

is it possible?

Thanks a lot.(sorry for my poor english)

TOPICS
Actions and scripting

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , May 03, 2017 May 03, 2017

That's why I said "a bit" 😄 But I didn't intepret question correctly.

In this case you need set-up event listener and then you can catch place event.

Look for "notifiers" in documentation and "arguments". Everthing in script listener log is also in arguments as action descriptor. And you can extract data from this descriptor.

Anyway this value is not stored anywhere in document by default. If you want this value after PS restart you should store it somewhere. Maybe in metatags.

From script listener

...

Votes

Translate

Translate
Adobe
Community Expert ,
May 01, 2017 May 01, 2017

Copy link to clipboard

Copied

If you embed the Smart Object there is no connection to the originally placed file anymore, only with Linked Smart Objects would this work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 01, 2017 May 01, 2017

Copy link to clipboard

Copied

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) {};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 02, 2017 May 02, 2017

Copy link to clipboard

Copied

c.pfaffenbichler: I a bit disagree. You can get link to embeded file, but you must open it. If you open embeded SO in PS as new document, then it creates .psb file in temp folder. On Windows: c:\Users\<yourProfileName>\AppData\Local\Temp\

I you close document, the .psb file is still there. It should be removed with Photoshop quit.

File name is stored in:

layer reference > smartObject > fileReference (CC2017)

Folder should be always temp folder.

You can read it only with AM code very similar to your code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 02, 2017 May 02, 2017

Copy link to clipboard

Copied

I stated

If you embed the Smart Object there is no connection to the originally placed file anymore

so I made no comment about the temp-file but the originally placed file.

But on rereading the original post

i drag a image from somewhere(for example:/Users/robberfree/Desktop/test.jpg) to PS,

then convert it to smart object.

I realise I misinterpreted and that the OP actually describes opening the file and then converting to a Smart Object – that would not change the path of the open file (as long as it has not been saved as a new file).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

That's why I said "a bit" 😄 But I didn't intepret question correctly.

In this case you need set-up event listener and then you can catch place event.

Look for "notifiers" in documentation and "arguments". Everthing in script listener log is also in arguments as action descriptor. And you can extract data from this descriptor.

Anyway this value is not stored anywhere in document by default. If you want this value after PS restart you should store it somewhere. Maybe in metatags.

From script listener:

var idPlc = charIDToTypeID( "Plc " );

    var desc3664 = new ActionDescriptor();

    var idIdnt = charIDToTypeID( "Idnt" );

    desc3664.putInteger( idIdnt, 4 );

    var idnull = charIDToTypeID( "null" );

    desc3664.putPath( idnull, new File( "D:\\Photos\\my\\path\\IMG_4419.JPG" ) );

    var idFTcs = charIDToTypeID( "FTcs" );

    var idQCSt = charIDToTypeID( "QCSt" );

    var idQcsa = charIDToTypeID( "Qcsa" );

    desc3664.putEnumerated( idFTcs, idQCSt, idQcsa );

    var idOfst = charIDToTypeID( "Ofst" );

        var desc3665 = new ActionDescriptor();

        var idHrzn = charIDToTypeID( "Hrzn" );

        var idPxl = charIDToTypeID( "#Pxl" );

        desc3665.putUnitDouble( idHrzn, idPxl, 0.000000 );

        var idVrtc = charIDToTypeID( "Vrtc" );

        var idPxl = charIDToTypeID( "#Pxl" );

        desc3665.putUnitDouble( idVrtc, idPxl, 0.000000 );

    var idOfst = charIDToTypeID( "Ofst" );

    desc3664.putObject( idOfst, idOfst, desc3665 );

executeAction( idPlc, desc3664, DialogModes.NO );

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

thanks Jarda Bereza and c.pfaffenbichler.

setup event listener maybe a little complex for my script.

when i asked the questions,

i just want to reuse the smart object image in my web app.

so i want to know the image source path.

now i just export the smart object  image every time in script.

    

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2017 May 04, 2017

Copy link to clipboard

Copied

LATEST

If I understand you correctly you may want to use Linked Smart Objects instead of Embedded ones.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines