6 Replies Latest reply: Feb 2, 2011 9:37 AM by JJMack RSS

    batch odd dimension images to square

    carleq Community Member

      Hi

       

      I have lots of images that are all different sizes and more coming.

       

      I need to create an action that makes these images square in px dimensions, with the new side dim. the dim. of the longest side.

       

      I need to add canvas (light gray) to the short side.

       

      I understand actions but not scripting.

       

      Thanks exceedingly.

        • 1. Re: batch odd dimension images to square
          JJMack Community Member

          I have created a script which is a Photoshop Plugin which can be downloaded it is one of my scripts included in my crafting actions package. The Plugin Script name is "AspectRatioSelection.jsx" all you need do is record a two step action that uses it.  Step 1 AspectRatioSelection 1:1 centered replace 0 feather. Step 2 menu Image>Image Crop you can batch that action. If you do not want to crop the image you could in the action a new layer fill it with gray then do the selection and delete the square selection to let the image below show through. If you have to add canvas to the short sides as you write you need to write a simple script to add canvas to the short side so both width and height are equal leave the anchor point the center and the have the added canvas  color be gray. If you look at some of the simpler scripts in my package I think you will be able to figure out a how to do it. The script will not be hard to write. If you can not figure it out Photoshop ships with a Plugin called the "ScriptListener" this Plug-in is install and uninstalled to have Photoshop record scripts.  You can install it start Photoshop create a new document and the add canvas to the document then exit Photoshop. Uninstall the plugin then look on your desktop for you will find two Photoshop scrip files one VSB and one Javascript with two steps new document and add canvas.  From the javascript one it should be east to create a javascript function to add canvas.  All your script would need to do is find the current document's longest size and use the function to make both the wdith and height this size..  Use one of my simple scripts as a script template. Photoshop also shaips with some scripting guide PDF files.

           

          http://www.mouseprints.net/old/dpr/JJMacksCraftingActions.zip

          Contains:

          Action Actions Palette Tips.txt

          Action Creation Guidelines.txt

          Action Dealing with Image Size.txt

          Action Enhanced via Scripted Photoshop Functions.txt

          CraftedActions.atn Sample Action set includes an example Watermarking action http://www.mouseprints.net/old/dpr/WM900x600.jpg

          Sample Actions.txt Photoshop CraftedActions set saved as a text file. This file has some additional comments I inserted describing how the actions work.

          12 Scripts for actions

          • 2. Re: batch odd dimension images to square
            Michael L Hale Community Member

            If I understand what you want, set the background color to your light grey then run this script with an open document.

             

            var savedRuler= app.preferences.rulerUnits;
            app.preferences.rulerUnits = Units.PIXELS;
            var w = app.activeDocument.width;
            var h = app.activeDocument.height;
            if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
            if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
            //if w==h already square
            app.preferences.rulerUnits = savedRuler;
            

            You should be able to call the script from an action and batch the action to process all your images at once.

            • 3. Re: batch odd dimension images to square
              carleq Community Member

              Mr Hale

               

              THE ANSWER. Thanks for workflow glue. Looks like this will work, and i'm beginning to understand scripts!

              • 4. Re: batch odd dimension images to square
                JJMack Community Member

                Michael  you make it to easy for them how will they ever learn?

                • 5. Re: batch odd dimension images to square
                  carleq Community Member

                  JJMack,

                   

                  I could also mark this helpful because laughter is the soul's best medicine!

                   

                  Honestly, your original message was very resourceful.

                  • 6. Re: batch odd dimension images to square
                    JJMack Community Member

                    carleq wrote:

                     

                    i'm beginning to understand scripts!

                    If you want to understand scripts better try these links  http://morris-photographics.com/photoshop/tutorials/scripting1.html and http://morris-photographics.com/photoshop/tutorials/scripting2.html  I found Trevor Morris. introduction and sample scripts a great starting point.  You may also want to look at my crafting actions package you may learns some thing about Actions as well as Scripts you don't know today.