17 Replies Latest reply: Aug 13, 2012 5:04 PM by JJMack RSS

    Insert Smart Images in Template

    ocphotog

      I need a script that would let me place an image in a  template opening. I would like it to open a directory to choose the file to insert, resize it to fit the template opening, but keep it as a smart object so that it can be resized if necessary. I found this in this thread  http://forums.adobe.com/message/3329062      and     http://forums.adobe.com/thread/455645    and it seems to fit the bill but I cannot find any script that uses it. Can anyone direct me to something?  Thanks.

       

      Stdlib.insertImageIntoSelectionAsSmartObject(doc, layer, im, fit)

        • 1. Re: Insert Smart Images in Template
          Muppet Mark Community Member

          If you look at your first link you will see that code is provided by xbyor its part of his photoshop toolkit… Have you installed this?

          • 2. Re: Insert Smart Images in Template
            ocphotog Community Member

            Yes, I have his folder of scripts. He has a script called InsertImage.jsx but that only resizes and places the image into the template. It doesn't come in as a smart object so that I can resize it, and it doesn't adjust if the template opening is square. So if I'm trying to insert a horizontal image in the opening it inserts it with the longer dimensions filling the sides of the square instead of the tob/bottom.

            • 3. Re: Insert Smart Images in Template
              Muppet Mark Community Member

              and you have the last parameter fit as false?

              • 4. Re: Insert Smart Images in Template
                ocphotog Community Member

                I'm a bit awkward at using these scripts. Do I just call the InsertImage script from photoshop or do I have to modify his existing script? I just not sure what to do.  Thanks!

                • 5. Re: Insert Smart Images in Template
                  JJMack CommunityMVP

                  You could look at my Photoshop Photo Collage Toolkit

                  Photo Collage Toolkit UPDATED June 12, added Picture Package Support via PasteImageRoll and BatchPicturePackage scripts.

                   

                  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 eleven 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. ChangeTextSize.jsx - This script can be used to change Image stamps text size when the size used by the populating did not work well.
                  7. PopulateCollageTemplate.jsx - Used to Automatically populate a Photo Collage template and leave the populated copy open in Photoshop.
                  8. BatchOneImageCollage.jsx - Used to Automatically Batch Populate Collage templates that only have one image inserted. The Collage or Image may be stamped with text.
                  9. 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.
                  10. BatchPicturePackage.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder
                  11. PasteImageRoll.jsx - Paste Images into a document to be print on roll paper.

                   

                  Documentation and Examples

                   

                  Note : there are Bugs in CS6;  Do not set your Pfererence to edit in Floating windows leave the option "Open documents in Tabs" checked  You must Also set your Photoshop Preferences Interpolation to something other then Photoshop's default "Bicubic Automatic" for adobe failed to add code for that change in to scripting.  If set to "Bicubic Automatic" when my scripts try to retrieve the interpolation preference a Photoshop internal error happens.

                  • 6. Re: Insert Smart Images in Template
                    ocphotog Community Member

                    I had actually looked at your work first but it was more of an interactive set of panels from what I can tell. I just wanted to work one image at a time. 

                     

                    DesiredWorkflow:

                     

                    Open Template

                    Click on One opening

                    Click on Insert action script, pick photo

                    Photo is inserted as smart object for possible resize.

                    Rince and Repeat.

                     

                    Would something from your set work for me?

                     

                    Thanks!

                    • 7. Re: Insert Smart Images in Template
                      JJMack CommunityMVP

                      IMO Yes and give you more options to boot.

                       

                      What you want to do is more or less what the interactive populate collage script does. There is one difference the script picks the opening hihjlights the opening to be populated then put you in an image selection dialog when you select the image the script places the image into the opening transforming it to fit. Then it puts you in an interactive transform on the picture so you can tweak the transformed placement.

                      Video Interactively Populated a Photo Collage Template  

                       

                      Message was edited by: JJMack

                       

                      The Script Dialog what you call a panel let you choose the Template to open and populate and  to set optons like Stamp File names in the images where the stamp should be on the image and if a text layer styles should be added to the text layers also  wether or not to add a layer styles to the smart object images layers.

                      • 8. Re: Insert Smart Images in Template
                        ocphotog Community Member

                        Gave the scripts a try this morning and unfortunately my templates are set up differently than yours so I get some error messages when using the scripts.

                         

                        1. The script is looking for a background layer and most of my templates do not have them.

                         

                        2. The script is looking for Alpha Channels and my templates do not use them, but rather there is a layer for each opening.

                         

                        3. I opened one of your templates and when I ran a script I got an error about not finding the My Picture folder. It still will allow me to choose an image but I have to hit OK first for the script to continue. The script works great if I had mine set up the same way but that would take a long time to convert all of them.

                         

                        Not sure if I can change the script to work with layer openings and not Alpha channels.

                        • 9. Re: Insert Smart Images in Template
                          JJMack CommunityMVP

                          Your templates most likely can be made compatable with my scripts. A backround layer is required but it dose not have to be visible. Its required for my script want to place in images above it and know they are  just above the bottom layer.  Your  templates must likely have layer mask or cutouts for images. All you need do is to make a selection that represents the size placement and shapes of your collage's images and save the selections as alpha channels named "Image 1", "Image 2" ... "Image N"

                           

                          Post one of your PSD template files  I'll have a look to see if they are easy to be made compatable with my scripts I find most templates are easy to be made compatable.  It would be way easier to make templates compatible then to program scripts to populate the kind of templates you now use. There are only four simple rules templates need to use.

                           

                          There is also an outside chance that the script LayerToAlphaChan.jsx - Used to convert a Prototype Image Layer stack into a template document. may be able to help make alpha channels for you.

                           

                          As for the starting folders for images and templates they can be anywhere there are hard coded variable in the scripts that you can change to suite your environment. All is spelled out in the help documentation.

                          the scripts start with a section like this the last two vars are the defailt template and image paths.

                          /////////////////////////////////////////////////////////////////////////////////

                          ///////////////////////CUSTOMIZE Here////////////////////////////////////////////

                          /////////////////////////////////////////////////////////////////////////////////

                          // Some Hard Coded variables that some day I may put into the dialog options area

                           

                          var imageStyleList = ['Default Style (None)','Photo Collage Style 1','Photo Collage Style 2','Photo Collage Style 3','Photo Collage Style 4','Photo Collage Style 5','Photo Collage Style 6','Photo Collage Style 7','Photo Collage Style 8','Photo Collage Style 9'];

                          var imageStyleDefault = 0;                              // imageStyleList index number

                           

                          var textSizeFactor = 4;                                        // > 1 scales down text size

                          var textFont = "ArialMT";                              // Photoshop internal font name

                          var textAngle = -10;                                        // center text angle

                          var textColor = new SolidColor;                              // text color

                              textColor.rgb.red = 255;

                              textColor.rgb.green = 255;

                              textColor.rgb.blue = 255;

                          var textStyleList = ['Default Style (None)','Shiny Metal','Shiney Metal No Stroke','Strong Metal','Strong Metal No Stroke','Clear Emboss - Inner Bevel','Clear Emboss - Outer Bevel','JJMack Overlay'];

                          var textStyleDefault = 0;                       // textStyleList index number

                          var textLocationDefault = 7;                    // text Location Default Bottom Center

                           

                          var templateFolder = "C:/Program Files/Adobe/Adobe Photoshop Templates/";

                          var imagePath = "~/My Documents/My Pictures/";

                            // End hard coded variables

                          /////////////////////////////////////////////////////////////////////////////////

                          /////////////////////////////////////////////////////////////////////////////////

                          /////////////////////////////////////////////////////////////////////////////////

                           

                          Message was edited by: JJMack

                          • 10. Re: Insert Smart Images in Template
                            JJMack CommunityMVP

                            If the script LayerToAlphaChan.jsx is able to convert your image layers to alpha channels there is a script in my crafting actions package that could be used to add background layer to templates that do not have background layers.

                            Crafting Actions Package Contains

                            Example

                            Download

                             

                            The script named SelectBackground.jsx you may be able to record a Action that uses SelectBackground.jsx followed by LayerToAlphaChan.jsx Then batch that action to convert your templates in your Template folder to compatible templates in a new Template Folder.

                             

                            SelectBackground is a very siimple script

                            // A Script by JJMack's Designed for use with Custom Mat Actions

                             

                            // This script targets the background if there is one or

                            // adds a new tageted background layer if there wasn't one.

                             

                            // This script is supplied as is. It is provided as freeware.

                            // The author accepts no liability for any problems arising from its use.

                            /*

                            <javascriptresource>

                            <about>$$$/JavaScripts/SelectBackground/About=JJMack's Select Background.^r^rCopyright 2009 Mouseprints.^r^rScript utility for action.^rNOTE:Select Background adding one if need be!</about>

                            <category>JJMack's Action Utility</category>

                            </javascriptresource>

                            */

                             

                            // enable double-clicking from Mac Finder or Windows Explorer

                            #target photoshop // this command only works in Photoshop CS2 and higher

                             

                            // bring application forward for double-click events

                            app.bringToFront();

                             

                            // ensure at least one document open

                            if (!documents.length) {

                                      alert('There are no documents open.', 'No Document');

                            }

                             

                            // if at least one document exists, then proceed

                            else {

                                      main();

                            }

                             

                            ///////////////////////////////////////////////////////////////////////////////

                            // main - main function

                            ///////////////////////////////////////////////////////////////////////////////

                            function main() {

                                      try {

                                                // declare local variables

                                                var layers = activeDocument.layers;

                                                activeDocument.activeLayer = layers[layers.length-1] // Target Bottom Layer

                                                if ( activeDocument.activeLayer.isBackgroundLayer ) { return; } // quit

                                                app.activeDocument.artLayers.add()

                                                // declare local variables

                                                var newlayers = app.activeDocument.layers;

                                                // arrange layers so new layer added is at bottom

                                            newlayers[0].move(newlayers[newlayers.length-1], ElementPlacement.PLACEAFTER);

                                                // Make it a Background Layer

                                                activeDocument.activeLayer.isBackgroundLayer=1

                                      }

                             

                                      // display error message if something goes wrong

                                      catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }

                            }

                             

                            • 11. Re: Insert Smart Images in Template
                              ocphotog Community Member

                              Wow, thanks for all the help. I'll try to get more into this over the weekend. I tried to upload one of my templates to see how most are set up but this program won't let me upload a PSD file.

                              • 12. Re: Insert Smart Images in Template
                                JJMack CommunityMVP

                                You need to upload PSD to a site for sharing files you can also e-mail one as an attachment jjmacks@hotmail.com

                                • 13. Re: Insert Smart Images in Template
                                  JJMack CommunityMVP

                                  Sent you e-mail with attachments an Action, a Script and a link to your sample template.  If you reverse the stacking order of your image layers before doint the conversion tmahes will pe populated from left to right. The way it is now images will be populated right to left.

                                  Images are populated above the background layer from the botton layer to the top image layer in the layer stack.

                                  • 14. Re: Insert Smart Images in Template
                                    ocphotog Community Member

                                    Thanks for your undying efforts on this. I downloaded the script and action, and added them to my actions and scripts folder, then put the action in the action pallet. For some unknown reason the action is there but when I click to open the action steps there are no scripts where the script steps are. Any idea what's going on? I loaded some other actions earlier today and the same thing happened, no scripts where the script step is. I have the scripts in the scripts folder and could add them manually but I'm not sure which two scripts you put in the action. This is Photoshop CS3 ver 10.0.1

                                    • 15. Re: Insert Smart Images in Template
                                      JJMack CommunityMVP

                                      Adobe changed the was script are recorded in newer versions of photoshop. You will need to record the twi steps on your CS3

                                       

                                      In the Actions in the action palette in the action  you should see a Stop step followev by two script steps. Highlight the two script steps and drage them to the trash can in the Actions palette.

                                       

                                      Open one of your template files the in the Actions Palette highlight the Convert Template action and click the Play button.  The Action shouls play and stop after you click the stop button the delete current layer step should be highlighted. Hihglight the Stop step above it instead.

                                      The click on the record button.

                                      Use menu File>Scripts>SelectBackground

                                      Use menu File>Scripts>LayerToAlphaChan

                                      click on the stop recording icon in the action palette

                                      Highlight the ConvertTemplate action set

                                      Use the Actions Palette fly-out menu iten Save Action

                                      save the action set the action set should now work ou ypour CS3 system

                                      • 16. Re: Insert Smart Images in Template
                                        ocphotog Community Member

                                        Thanks, I thought my PS caught a bug. As usual Adobe changes things to make it not backward compatible. The script works very well and with not too many changes to my existing templates. I'll make changes as I encounter my template use. Thanks again!

                                        • 17. Re: Insert Smart Images in Template
                                          JJMack CommunityMVP

                                          Thing are backwards compatible it hard to make programs forward compatible for its has not been programmed yet. That is your case CS3 is not forward compatible with cs5. I had created the action with CS5. 

                                           

                                          I like CS5 way for I can install scripts in my script tree and link all Photoshop versions script folder to my install tree. That way all version of Photoshop the will look for Script by name will work.

                                           

                                          However CS2 and CS3 where my scripts will also work from the scripts menu if used in actions need to be recorded in actions in CS2 or CS3.  The Scripts location must never change and they must be install in the same location on all Machines. For CS2 and CS3 action player will not look for scripts by name they expect the scripts full path to be recorded in the action step..

                                           

                                          There is more flexability the new way actions work.  The Script are normally used from menu File>Scripts>List Script Name. Therefore scripts can be installed anywhere on one's system and as long as the location in linked into Adobe Photoshop Script Path they will be listed in the Scripts List by name and findable. Enen in actions recorded in CS4,5 or 6.