Skip to main content
Participating Frequently
July 26, 2011
Answered

How to import a picture into a Psd file using codes?

  • July 26, 2011
  • 1 reply
  • 1910 views

I'm trying to import a picture into a psd file as a new layer, but i can't find the method of photoshop object in visual studio 2010 object browser. Is it possible to do this job using vb.net codes?

Any suggestion will be gratuated!

This topic has been closed for replies.
Correct answer Michael_L_Hale

I beleive Michael L Hale stated that he used the ScriptListener to generate code for PhotoShop "menu File>Place".  Many things can not be done through in Photoshop Scripting through the Adobe's normal scripting methods Adobe provided for scripting.  However Adobe also supplied  the ScriptListener.8li plugin which when installed is a bit like the actions palette's action recorded without controls.  Everthing that can be recorded in Photoshop is written to two files on your desktop in script code one in Javascript the other VBS.  The Script code use an Action Manager Method so thing not posible with normal scripting methods can be use in scripts.  The only way to start and stop recording these two script files it to install ScriptListener.8li before you start Photoshop and to uninstall it after you exit Photoshop. Awarkward but better then nothing there is no logic just step, step, step like actions and the code is not all that readable.  However you can take that code and modify it to use vars to turn steps into javascript functions and whatever VBS uses.

For example Place

REM =======================================================

DIM objApp

SET objApp = CreateObject("Photoshop.Application")

REM Use dialog mode 3 for show no dialogs

DIM dialogMode

dialogMode = 3

DIM idPlc

idPlc = objApp.CharIDToTypeID( "Plc " )

    DIM desc3

    SET desc3 = CreateObject( "Photoshop.ActionDescriptor" )

    DIM idnull

    idnull = objApp.CharIDToTypeID( "null" )

    Call desc3.PutPath( idnull, "D:\\Temp\\Portrait\\dsc6234.psd" )

    DIM idFTcs

    idFTcs = objApp.CharIDToTypeID( "FTcs" )

    DIM idQCSt

    idQCSt = objApp.CharIDToTypeID( "QCSt" )

    DIM idQcsa

    idQcsa = objApp.CharIDToTypeID( "Qcsa" )

    Call desc3.PutEnumerated( idFTcs, idQCSt, idQcsa )

    DIM idOfst

    idOfst = objApp.CharIDToTypeID( "Ofst" )

        DIM desc4

        SET desc4 = CreateObject( "Photoshop.ActionDescriptor" )

        DIM idHrzn

        idHrzn = objApp.CharIDToTypeID( "Hrzn" )

        DIM idRlt

        idRlt = objApp.CharIDToTypeID( "#Rlt" )

        Call desc4.PutUnitDouble( idHrzn, idRlt, 0.000000 )

        DIM idVrtc

        idVrtc = objApp.CharIDToTypeID( "Vrtc" )

        DIM idRlt

        idRlt = objApp.CharIDToTypeID( "#Rlt" )

        Call desc4.PutUnitDouble( idVrtc, idRlt, 0.000000 )

    DIM idOfst

    idOfst = objApp.CharIDToTypeID( "Ofst" )

    Call desc3.PutObject( idOfst, idOfst, desc4 )

Call objApp.ExecuteAction( idPlc, desc3, dialogMode )


You can, like me, just leave the scriptlistener plug-in installed all the time. It really does not effect proformance unless the log file are very big. I just keep a eye on the log file and delete it when it starts to get too large. Also it you do not want the output of both the js and vbs logs just set the one you don't want to read only. Photoshop will ingore it and only write to the one you want.

If you do want to uninstall the plug-in a quick way to do so is to rename it by placing a '~' at the start of the name.

1 reply

Inspiring
July 26, 2011

I have no idea about VB but do you mean as a smart object? You have a boolean in the app open options to do that… You can duplicate these from one document to another if need be…

Participating Frequently
July 26, 2011

Not exactly,maybe. The picture was in my computer,on the desktop,for instance.I'm trying put this picture into another psd file.Michael L Hale figured out to do this using java codes. I'm trying to convers the code to vb.net like.Didn't work by now.

Participating Frequently
July 26, 2011

It works now!