8 Replies Latest reply on Feb 19, 2015 8:12 AM by JJMack

    Script to frame multiple designs in various colours and save each image.

    libertinex

      I sell prints online, and have a template of a frame, but I would like to know if there is a script which can be used to input maybe 10 image files into the frame template, and save each file as its own jpeg.

       

      Hope that makes sense.

       

      Thanks

        • 2. Re: Script to frame multiple designs in various colours and save each image.
          libertinex Level 1

          Brilliant thank you, so how do I now use the below in PS (I am on CS5)

           

          thanks again for your help

           

          // 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;*.jpg", 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], theLayer);

                              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) != null || theFile.constructor.name == "Folder") {

                    return true

                    };

               };

          ////// replace contents //////

          function replaceContents (newFile, theSO) {

          app.activeDocument.activeLayer = theSO;

          // =======================================================

          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

          };

          • 3. Re: Script to frame multiple designs in various colours and save each image.
            c.pfaffenbichler Level 9

            Paste the text into a new file in ExtendScript Toolkit and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.

            After restarting Photoshop the Script should be available under File > Scripts and can be assigned a Keyboard Shortcut directly, recorded into an Action or started from ExtendScript Toolkit directly.

             

            Then select the Smart Object that is to be replaced and start the Script.

            • 4. Re: Script to frame multiple designs in various colours and save each image.
              JJMack Most Valuable Participant

              Yes however the templates would need to have a consistent design to be populated automatically.   My Photoshop  Photo Collage Toolkit contains a template design that only has four simple rules that I find quite flexible.  There are populating scripts.  Templates can be tested, populated interactively, populated Automatically and batched populated.

               

              Photo Collage Toolkit

               

              Photoshop scripting is powerful and I believe this package demonstrates this A video showing a 5 image collage PSD template  being populates with images:

               

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

              1. Size the photo collage templates for the print size you want - width, height and print DPI resolution.
              2. Photo collage templates must have a Photoshop background layer. The contents of this layer can be anything.
              3. Photo collage templates must have alpha channels named "Image 1", "Image 2", ... "Image n".
              4. Photo collage templates layers above the background layers must provide transparent areas to let the images that will be placed below them show through.

               

              There are twelve 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.
              12. PCTpreferences.jsx - Edit This File to Customize Collage Populating scripts default setting and add your own Layer styles.

               

              Documentation and Examples

              • 5. Re: Script to frame multiple designs in various colours and save each image.
                c.pfaffenbichler Level 9
                Yes however the templates would need to have a consistent design to be populated automatically.

                More or less, I guess …

                 

                Maybe the original poster’s needs might even be sufficiently addressed with Data Driven Graphics

                https://helpx.adobe.com/photoshop/using/creating-data-driven-graphics.html

                but my personal preference would be Scripting …

                • 6. Re: Script to frame multiple designs in various colours and save each image.
                  JJMack Most Valuable Participant

                  Yes data Driven graphics is an other option. However for me who can not type creating the CSV file is a hard task..

                  • 7. Re: Script to frame multiple designs in various colours and save each image.
                    c.pfaffenbichler Level 9

                    I am pretty much just aware that the "Data Driven Graphics" feature exists but I practically do not use it myself …

                    • 8. Re: Script to frame multiple designs in various colours and save each image.
                      JJMack Most Valuable Participant

                      My script only have limited text support the file name or part of the file name and can only be placed on the images in one of 9 locations and the same location will be used on all images in a collage when my the text option is used.  Scripting is hard for me for I can not type but a finger or two at a time.  Sill I use it over data driven graphics for creating Data Driven Graphics templates and CSV files is harder and less flexible for me then my templates and scripts.