4 Replies Latest reply on May 12, 2017 6:56 AM by ghoniba

    Creating A Square Crop...

    ghoniba

      Hey Guys,

       

      I have several hundred images that vary in dimensions as they have been cropped down by a photographer for their best 'look'. Some are supplied portrait and some are landscape. What I need to do is create a canvas size that is perfectly square for each image based on the longest length of each image so that nothing is cropped off. I will then fill in the background where needed. For instance, I may have an image that is 15" by 9" I will then create a canvas size that is a 15" by 15" square so that I don't crop anything off. I will then manually extended the background where short to give me a full 15" square image. Of course as I have said, not all of the images are supplied the same size. The dimensions will vary.

       

      Does anyone know how I can create an Action or something that can batch run these images to give me perfect squares  based on the longest side? Any ideas would be most appreciated.

       

      Thank you, Glenn

        • 1. Re: Creating A Square Crop...
          JJMack Most Valuable Participant

          That would be easy to script.  I do not believe a action even a conditional action could do that.  It would be simple to do with a Photoshop script. It could be a very simple script that only did that to a document.  You could record using the script in an action. Then batch that action perhaps using the Image Processor script.

           

          You could try to do more in the action.  Perhaps try to create an action the would try to do a content aware fill of the added canvas area s..

           

          Crafting Actions Package UPDATED Aug 10, 2014 Added Conditional Action steps to Action Palette Tips.
          Contains

          Example
          Download

          1 person found this helpful
          • 2. Re: Creating A Square Crop...
            ghoniba Level 1

            Thank you JJMack,

             

            I am not that familiar with scripts and would not know how to write one to perform this function. Do you offer a service to do this?

             

            Glenn

            • 3. Re: Creating A Square Crop...
              JJMack Most Valuable Participant

              Actions can use scripts and script can use actions.  Actions are easy to record edit and debug.  Script are programs so you need to know something about programming.  If your mind can come up with the logic if my image is wider than it is high add canvas to the height to make the canvas as high as it is wide or if the image is higher than it is wide add canvas to the width to make the image as wide as it is high.  Then you know something about programming.  Now what you need to do is use a computer language so you computer will do you what you mind came up with.  There the rub and were users freak out.  The thing is they should not.   There are many computer languages and some are designed to be relatively easy to use and do not need to be elaborate or compiled into machine code.  Scripting language are goof example.   JavaScript  I use but actually do not know well is available on Mac and PC so it the best  scripting language to use for Photoshop Scripts.  Like Action have limits so does Adobe Photoshop scripting fot Adone Photoshop Document Object Model doe not cover all of Photoshop features.  However  anything the can be recorded or inserted into an action can be done in a script using Action Manager code.   Therefore Photoshop are Action on steroids your minds logic cam be included.

               

              If you look at my crafting actions package you will see I included a dozen scripts I wrote to be use in actions a few are complex and quite powerful. The majority of the scripts are small simple and easy to read.   They are in the package so you can seen that scripting basic Photoshop thing is actually not hard or scary.  I have a programming background was a paid programmer I did not go to school to become a Programmer.  I was hired by big blue to fix their machines.  Five years into that job my manager  took my tool bag and said John you now a programmer.  That was scary. I remained a programmer for the next 35 years and was well paid  all all learning was on the job with sleepless nights.     I retired 15 yeas ago when Java was young I never had toe learn it and object orianent programming was also the new kid on the block.

               

              Years ago there were no conditional Actions you could not tell if a document was a Landscape or a portrait in and action.  So one of the script I included in the crafting action package help a little in that area.   Conditional action are simple if condition is do this else do some other thing.   Only a few condition are supported all actions used in a conditional action need to be in the same action set they actions cam not be move to an other set and the set can not be renames.   IMO using a simple script step may  be better.

               

              Here in one I include in the package RotatePortrait.jsx read the script it scary the my script in more complex then it need to be actually a one liner would work if your Photoshop  ruler units are set to something other that percent for when set to percent width is 100% and height is 100%  comparing Height to width would compare equal.  

              "if (activeDocument.height > activeDocument.width) activeDocument.rotateCanvas(90);"

               

               

              /*

              <javascriptresource>

              <about>$$$/JavaScripts/RotatePortrait/About=JJMack's Rotate Portrait.^r^rCopyright 2009 Mouseprints.^r^rScript utility for action.^rNOTE:Rotate Portrait to Landscape!</about>

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

              </javascriptresource>

              */

              Rotate();

               

              function Rotate() {

              // validate that a document is open

              if (documents.length < 1) {

                alert("No Open Document!");

                return;

                }

              var orig_ruler_units = app.preferences.rulerUnits;

              app.preferences.rulerUnits = Units.PIXELS;

              // Rotate portrait to landscape orientation

              if (activeDocument.height > activeDocument.width) activeDocument.rotateCanvas(90);

               

              // Reset units to original settings

              app.preferences.rulerUnits = orig_ruler_units;

              }

              • 4. Re: Creating A Square Crop...
                ghoniba Level 1

                Hey JJMack,

                 

                I really do appreciate the effort you put into your reply. Unfortunately for me, I don't have the aptitude for programming and for that reason I got into something artistic! Bill Gates or Steve Jobs I am not! I did find someone that will write the script for me. Far less stressful and time consuming for me! Thank you. Take care.

                 

                Glenn