10 Replies Latest reply on Jul 27, 2011 8:47 PM by JJMack

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

    广陵散绝

      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!

        • 1. Re: How to import a picture into a Psd file using codes?
          Muppet Mark Level 5

          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…

          1 person found this helpful
          • 2. Re: How to import a picture into a Psd file using codes?
            广陵散绝 Level 1

            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.

            • 4. Re: How to import a picture into a Psd file using codes?
              JJMack Most Valuable Participant

              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 )

              1 person found this helpful
              • 5. Re: How to import a picture into a Psd file using codes?
                Michael L Hale Level 5

                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.

                • 6. Re: How to import a picture into a Psd file using codes?
                  Muppet Mark Level 5

                  I leave mine permanent… Mike you just answered what I was about to ask… Was wondering if the PC had optional 2 plug-ins installed… But no…

                  • 7. Re: How to import a picture into a Psd file using codes?
                    广陵散绝 Level 1

                    Thanks for your CODES!

                    I'm not familiar with photoshop objects. I'm still not sure under what circumstances should we use our own functions or just use the Method the Photoshop provide. For instance if i want to select a specific region of a balnk layer, i can find "Photoshop.selection.select" in the object browser,but i can't user this Method ,the problem is somthing like  using "Photoshop.actiondescriptor.putpath".

                    I'll try the sub function.

                    By the way,scriptorlistener is helpful.Thanks!

                    • 8. Re: How to import a picture into a Psd file using codes?
                      广陵散绝 Level 1

                      Thanks ,the scriptlistener is helpfu!

                      • 9. Re: How to import a picture into a Psd file using codes?
                        广陵散绝 Level 1

                        I think it is nice if the plug-ins works,that 's enough for me.You r right ,here we get two logs by only one plug-in.

                        • 10. Re: How to import a picture into a Psd file using codes?
                          JJMack Most Valuable Participant

                          In the Photoshop Windows forum I just saw a thread about some downloadable Scripts. One was named vScriptListener.jsx gives you some  control over the plugin. I created an action asigned to a F key to run it.  You can turn off its output by changing the state of a log files read only bit and also clear and look at a log files. http://www.mouseprints.net/old/dpr/vScriptListener.jsx

                           

                          // AUTHOR: James A. Taylor
                          // DESCRIPTION: Controls aspects of the Photoshop script listener output.