29 Replies Latest reply on Jul 31, 2018 6:26 AM by Kukurykus

    Place images to a specific spot in a template

    Melissa Moulden

      I am trying to create an action that will drop images into a specific spot in another document and save it with a certain file name. After the first image is dropped in and saved, I want my next image to do the same and so on. I have all my images cropped to the correct ratio and being pulled from a folder on my desktop. I have my template open in Photoshop where I want my images from that folder to be dropped into. Is this possible?

       

      Any help is greatly appreciated!!

       

      Melissa

        • 1. Re: Place images to a specific spot in a template
          JJMack Most Valuable Participant

          Melissa

          What you want to do can be done but it is complex and actions have some limitations and can not use logic without using a script or two. File saving  can be tricky for an action will always save the same file name or use the current document name saved either overwriting the file or saving it to some other particular folder. Action that populate a template can be created but it will always populate the same number of images because an action can not use logic to find out how many spots there are to populate. There are different ways to drop an image into the active document you can paste into an area or just past in the image in as a new layer.  You can also Place images in as smart objects. Each method has some advantages and disadvantages. Layers can also be aligned with selections and layers can be transformed in size.  Your best off creating rule for creating a template and have a plan as to how your going to populate these templates that follow your rules. To protect the template from alteration you may want to dupe the template close the original and work on the duped version. When you dupe the template you can give the dupe a name if you do not name it the new document will have the same name with copy appended.

           

          Scripting is more powerful then Action but they are programs that are written in a scripting language. Photoshop supports three languages. VBS, Applescript and Javascript. Only Javascript is supported on both the MAC and PC platforms.  Even using Javascript you may need to code the script to work on both platforms for I'm sure there are some differences in the OS and file system the may need special handling to work on both platform.  From you description of you work-flow it is hard to tell exactly what you are doing.   If you trying simple create a photo Collage.  You may want to have a look at my free Package for Photoshop called "Photo Collage Toolkit" . I have been told this package works on a MAC but I created it and tested it on widows and got it To work with CS2, CS3, CS4 and CS5.

          .

          Photo Collage Toolkit UPDATED Sept 24, 2011 added a script to replace a Populated Layered Collage Smart Object Image with an other image with resizing.

          Photoshop scripting is powerful and I believe this package demonstrates this.

          The package includes four simple rules to follow when making Photo Collage Template PSD files so they will be compatible with my Photoshop scripts.

          There are eight scripts in this package they provide the following functions:

          1. TestCollageTemplate.jsx - Used to test a Photo Collage Template while you are making it with Photoshop.
          2. CollageTemplateBuilder.jsx - Can build Templates compatible with this toolkit's scripts.
          3. LayerToAlphaChan.jsx - Used to convert a Prototype Image Layer stack into a template document.
          4. InteractivePopulateCollage.jsx - Used to interactively populate Any Photo Collage template. Offers most user control inserting pictures and text.
          5. ReplaceCollageImage.jsx - use to replace a populated collage image Smart Object layer with an other image correctly resized and positioned.
          6. PopulateCollageTemplate.jsx - Used to Automatically populate a Photo Collage template and leave the populated copy open in Photoshop.
          7. BatchOneImageCollage.jsx - Used to Automatically Batch Populate Collage templates that only have one image inserted. The Collage or Image may be stamped with text.
          8. BatchMultiImageCollage.jsx - Used to Automatically Batch Populate Any Photo Collage template with images in a source image folder. Easier to use than the interactive script. Saved collages can be tweaked.

          Note: Rags Gardner www.rags-int-inc.com Photoshop Collage Template Builder script Copyright (c) 2006 builds layered Photo Collage Template psd files. Rags's has given me permission to include a modified version of his script in my package. The modification converts Rags's layered image template document into a flattened template compatible with Photoshop "Photo Collage Toolkit" package. There is also an option that will instead create a layered image stack like Rags's templates are these are also produced if you attempt to create a template with more then 53 images.

          Photoshop only supports up to 53 Alpha channels therefore with its design the Photo Collage Toolkit can only support collages with 1 to 53 images. I do not feel this is a big limitation for if you put 53 3:2 aspect ratio images on a large 16" x 20" paper they would need to be less then 1.9" x 2.86" in size if you wanted a frame around each and less then .95" x 1.43" on a 8" x 10" year book page size.

          While the maximum number of images in a collage is 53 you can actually create larger collages by populating a large number of images into several collages and then populate yet an other collage template with these populated collages. Each will be placed into the collage of collages as a single smart object layer. You may want to save the populates PSD file as Jpeg files first to cut down on the overhead of having large PSD file smart object layers in the collage of collages.

          Documentation and Examples


          • 2. Re: Place images to a specific spot in a template
            c.pfaffenbichler Level 9

            Personally I would prefer to use a template with a Smart Object in such a case and Replace Contents.

             

            What formats are the images to be placed, in which format what do you want the layered files saved, where to and with what names exactly?

            • 3. Re: Place images to a specific spot in a template
              c.pfaffenbichler Level 9

              Recently I’ve done something similar, so I could adapt that.

              On the lower left are the files that were selected in the Script’s dialog (all the same size, though), on the lower right are the resultant images, top center ist the template document with the Smart Object selected.

              switchSOPsdScr.jpg

              If you want to give it a try, paste the following text into a new file in ExtendScript Toolkit (part of Photoshop’s installation, /Applications/Utilities/Adobe Utilities-CS5/ExtendScript Toolkit CS5) and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.

               

              // replace smart object’s content and save psd;
              // 2011, use it at your own risk;
              #target photoshop
              if (app.documents.length > 0) {
              var myDocument = app.activeDocument;
              var theName= myDocument.name.match(/(.*)\.[^\.]+$/)[1];
              var thePath = myDocument.path;
              var theLayer = myDocument.activeLayer;
              // psd options;
              psdOpts = new PhotoshopSaveOptions();
              psdOpts.embedColorProfile = true;
              psdOpts.alphaChannels = true;
              psdOpts.layers = true;
              psdOpts.spotColors = true;
              // check if layer is smart object;
              if (theLayer.kind != "LayerKind.SMARTOBJECT") {alert ("selected layer is not a smart object")}
              else {
              // select files;
              if ($.os.search(/windows/i) != -1) {var theFiles = File.openDialog ("please select files", "*.psd;*.tif", true)} 
              else {var theFiles = File.openDialog ("please select files", getFiles, true)};
              if (theFiles) {
              // work through the array;
                        for (var m = 0; m < theFiles.length; m++) {
              // replace smart object;
                                  theLayer = replaceContents (theFiles[m]);
                                  var theNewName = theFiles[m].name.match(/(.*)\.[^\.]+$/)[1];
              //save jpg;
                                  myDocument.saveAs((new File(thePath+"/"+theName+"_"+theNewName+".psd")),psdOpts,true);
                                  }
                        }
              }
              };
              ////// get psds, tifs and jpgs from files //////
              function getFiles (theFile) {
                   if (theFile.name.match(/\.(psd|tif)$/i)) {
                        return true
                        };
                   };
              ////// replace contents //////
              function replaceContents (newFile) {
              // =======================================================
              var idplacedLayerReplaceContents = stringIDToTypeID( "placedLayerReplaceContents" );
                  var desc3 = new ActionDescriptor();
                  var idnull = charIDToTypeID( "null" );
                  desc3.putPath( idnull, new File( newFile ) );
                  var idPgNm = charIDToTypeID( "PgNm" );
                  desc3.putInteger( idPgNm, 1 );
              executeAction( idplacedLayerReplaceContents, desc3, DialogModes.NO );
              return app.activeDocument.activeLayer
              };
              
              • 4. Re: Place images to a specific spot in a template
                JJMack Most Valuable Participant

                When replacing contents you will have to resize the replaced contents if the replacement image is not the same size and aspect ratio as the smart object contends being replace. There is a transform associated with a smart object layer.  The original smart object layer has a transform associated with it and that transform will be applied to the replacement image.  In fact if you dupe the smart object layer not using new smart object via copy. Just a strait layer dupe you can have several layers all containing the single smart object with each layer having its own transform which locates its position and size. Replacing the content of any of those layers smart object changes the image on all the layers.  For a this type or collage to work correctly the original smart object image and the replacement need to be the same size.  I use Place and smart Object in my Photo Collage Toolkit.   I like to support any size image the only important thing is an image aspect ratios should closely match the aspect ratio of the template image aspect ratio.  They don't have to be same aspect ratio the scripts will fit all image into place but the apparent crop can adversely effect image composition.  Being they are smart objects they can be tweak by retransforming the placed image placement and size.

                • 5. Re: Place images to a specific spot in a template
                  c.pfaffenbichler Level 9

                  Nice explanation for the OP.

                  And the point you made in post 1 about integrating Scripts into Actions for the steps where Actions alone would fall short is also a valid one – but if in this case the names of the selected file is to be used for saving the new file it might be inconvenient if the selection and the saving would have to be done at two separate points in the Action.

                  • 6. Re: Place images to a specific spot in a template
                    JJMack Most Valuable Participant

                    Yes with actions you have few options when it come to file nameing.  Scripting is the way to go. 

                    • 7. Re: Place images to a specific spot in a template
                      SarahFaithMorris1600 Level 1

                      I can't figure out how to get this script to be able to open a folder.  When I run it , it's only letting me select PSDs on my desktop.  I'd like to be able to select files within a certain folder.  Can I change something to make it stop ghosting out folders in the opendialog command?

                      • 8. Re: Place images to a specific spot in a template
                        c.pfaffenbichler Level 9

                        On a Mac replace

                             if (theFile.name.match(/\.(psd|tif)$/i)) {

                        with

                             if (theFile.name.match(/\.(psd|tif)$/i) != null || theFile.constructor.name == "Folder") {

                        • 9. Re: Place images to a specific spot in a template
                          SarahFaithMorris1600 Level 1

                          Awesome, it works now.  I also modified it to include JPGs.  Thank you!

                          • 10. Re: Place images to a specific spot in a template
                            Bestsides

                            Thank you , JJ Mack!!! I have wanted to do this same thing Sara describes - For me I wanted to quickly and easily create Folder Preview Image JPEGs using several images inside of the folder. I was able to easily make an action to resize the images and save them to a folder. But I never fully figured out how to get those images on to my various templates (8 images, 16 images, etc...) and clipped to the masks. Your scripts are magical to me! I am not someone who knows how to script but I knew enough to know this was the best way to achieve what I wanted. Your Tool Kit and postings had great instructions and videos and have made one of my Mac tasks SO simple and such a time saver. THANKS!!

                            • 11. Re: Place images to a specific spot in a template
                              schroef Level 1

                              c.pfaffenbichler Doesnt work on OSX, it returns

                               

                              'Null is not an Object'

                              • 12. Re: Place images to a specific spot in a template
                                c.pfaffenbichler Level 9

                                What does not work?

                                Please post the Script you use and a screenshot of Photoshop (including the pertinent Panels) at time of the error.

                                • 13. Re: Place images to a specific spot in a template
                                  schroef Level 1

                                  Re: Place images to a specific spot in a template

                                   

                                  This wont work, i dont get to pick a folder nor does go to a folder. Tried both methods. I keeps showing files only.

                                   

                                  But im not even sure this what i was looking for, it seems this script places links in open images according do a selected llist from file selection.    

                                  • 14. Re: Place images to a specific spot in a template
                                    c.pfaffenbichler Level 9

                                    Do you work on a Mac?

                                    And why did you append the issue to this thread?

                                    • 16. Re: Place images to a specific spot in a template
                                      c.pfaffenbichler Level 9

                                      Once again: Please post the Script you use.

                                      • 17. Re: Place images to a specific spot in a template
                                        chenet0005 Level 1

                                        Thank you jjmack... thanks for script...

                                        I modified the Batch Picture package  script for my own... The original script populates single photo to all alpha layers, so i changed a little.

                                        • 18. Re: Place images to a specific spot in a template
                                          JJMack Most Valuable Participant

                                          It good to hear you found  my scripts helpful.   May I ask what you changed my Batch Picture package  script  to do for you?

                                          • 19. Re: Place images to a specific spot in a template
                                            Stephen_A_Marsh Adobe Community Professional

                                            Melissa, I know that you are now sorted, however this may help somebody else. Sometimes you need scripts, other times all you need to do is look at the problem from a different angle and an action will do the job. I can’t write scripts from scratch, so I usually have to rely on actions.

                                             

                                            Rather than attempting to insert the variable named/content files into a static template – place the static template into the variable files! This will preserve the critical variable filename. You will probably need to rearrange the layer order using relative layer targeting and stacking. The variable files can be sized to include the template and the template location and placement can be recorded and used on all variable files as this does not change. Elements can be aligned and moved to specific relative or absolute positions.

                                             

                                            Example here:

                                             

                                            Re: Simple action to replace image from walls

                                            • 20. Re: Place images to a specific spot in a template
                                              Kukurykus Adobe Community Professional

                                              One time visitor. She didn't check what people answered to her question since question was more important than answer?

                                              • 21. Re: Place images to a specific spot in a template
                                                JJMack Most Valuable Participant

                                                Stephen Melissa post is 7 years old why post this now?  That action also flatten and has a place step and no details of the place step is display.  If it an intaractive step the user would need to select the a image place during the place size position the image  and after that may have to mask the placed layer to shape.  Then there a layer move to where? If the document was just falttened the a place done nothing can be moved below the background layer the placed layer would be on top.  Have I missed something?

                                                action.png

                                                • 22. Re: Place images to a specific spot in a template
                                                  Stephen_A_Marsh Adobe Community Professional

                                                  JJMack wrote:

                                                  Stephen Melissa post is 7 years old why post this now?

                                                   

                                                  Why post now? JJ, you posted a new reply to the topic, which pushed it to the top of the list when I viewed the forum, which brought it to my attention.

                                                   

                                                  Why post now? I stated that in the first sentence of my reply: “…however this may help somebody else” – which is the whole idea of these forums. I believed that I had something of value to add to the topic.

                                                   

                                                  The age of the thread should make no difference, if it did Adobe’s forum software would lock the topic after a certain amount of time. Or the forum software would have a warning that the original topic was created at a certain date etc. I often update old posts with cross links or new information if I stumble across them.

                                                   

                                                  This generic question is timeless and is repeated month after month, year after year. If my post helps somebody then I am happy.

                                                  • 23. Re: Place images to a specific spot in a template
                                                    JJMack Most Valuable Participant

                                                    Actually my post was a reply to a post made yesterday.  I was hoping to hear what they added to my script and your post may have killed any chance of that.

                                                     

                                                    Also the Action download link in the thread you post in no longer valid and the Action write up is very poor  and would not work if users tried to create it from what is posted. That thread is not timeless.

                                                    • 24. Re: Place images to a specific spot in a template
                                                      AG_Ps_100 Level 1

                                                      guys you gave solutions but do you think a solution for my template can work?

                                                       

                                                      I have a template that i've put 10 rectangle shapes (black fill with 4px white stroke) and then i create clipping mask:

                                                      template.JPG

                                                       

                                                      i don't mind using Smart Object as well, although it might be more work.

                                                       

                                                      automating this will be awesome.

                                                      • 25. Re: Place images to a specific spot in a template
                                                        JJMack Most Valuable Participant

                                                        Templates are normally for Pictures and text not for populating shapes.    To make  a Photo collage template for what you show for Photo images would only require a empty Background, ten Alpha channels to map the Image Locations, Sizes and their Shapes.  On top of the background layer you would add your Text Layer and confine the text to the center area where your image will not be located, or you can add text over the image areas to overlay you image that will be placed in below the text.   I would not know how to populate a template with shapes.

                                                         

                                                        Scripts can also add text layer on image like filenames. And layer styles can be added to populated image layers.  You can customize my scripts and add your additional layers styles.  Like A stroke around a image.

                                                         

                                                        Smart Object layer are not additional work but they do have a higher overhead then a pasted in layer.   Smart object Layer can be tweaked, resized etc image quality will be preserve using Smart Object layers. Normal pixels layers do not have the same attribute as a smart object layer.

                                                         

                                                        The Template  I used Dropbox - 10-Image.psd the template PSD is 12" x 12" with a 300DPI resolution.  The Portrait image locations have an aspect ratio near 2:3 the populated image will be 2.8" by 3.8" at a 300DPI resolution.

                                                        ]Capture.jpg

                                                         

                                                        A video running one of my scripts.

                                                        • 26. Re: Place images to a specific spot in a template
                                                          Stephen_A_Marsh Adobe Community Professional

                                                          Actually my post was a reply to a post made yesterday.  I was hoping to hear what they added to my script and your post may have killed any chance of that.

                                                           

                                                          Also the Action download link in the thread you post in no longer valid and the Action write up is very poor  and would not work if users tried to create it from what is posted. That thread is not timeless.

                                                           

                                                          JJMack, it appears that your Adobe account has been hacked by a petulant and petty child that has not learned to share the public sandpit and mistakenly believes that it is their private toy. Perhaps it is time to change your password and regain control of your account so that the forum can return to reading your regularly eloquent posts.

                                                          • 27. Re: Place images to a specific spot in a template
                                                            JJMack Most Valuable Participant

                                                            I feel most post should be made in in a timely manner and have value.  The post you referred to was most like good at one time.

                                                            • 28. Re: Place images to a specific spot in a template
                                                              Kukurykus Adobe Community Professional

                                                              That is good they didn't lock this topic after someone refreshed it. Too bad when you do it on (regular) Adobe Ps forum it is different. I noticed some moderators are incomprehensible. They lock topics and ask to create new one right after someone posted there something after few years. For me that's completely stupid to create new topic if the question of new comer is related to old question. Some moderators should change approach to a matter.

                                                              • 29. Re: Place images to a specific spot in a template
                                                                Kukurykus Adobe Community Professional

                                                                I think it's his passion, and he really doesn't care someone will read his posts. He does it for himself mainly, shares that is valuable and can be used for others as far as that's related to theard. Additionally when he finds it's useful for people he's going to serve his help, so I don't think that answering after many years to some problem shuld be criticised even if we do know one who aksed question won't appreciate it just checking answer. That still may be used by someone new instead of creating a topic to ask for something that already was said.