Skip to main content
February 6, 2020
Answered

Cropping to a fixed ratio as an action

  • February 6, 2020
  • 2 replies
  • 7521 views

 

I have a batch of images of differing resolutions but at landscape orientation. I want to batch crop these images to all have a similar ratio. When I load the Crop tool and select my custom ratio, the tool manages to create a rectangular selection in the middle of the image at the 2.8x5 ratio that I've selected:

 

This tool works regardless of what image I select. When I attempt to automate this as an action, the action uses the initial dimensions of the image I used to create the action as the basis of my image: 

 

This happens regardless of whether I hit enter or use the menu to crop my image when creating the action.

 

I've tried recreating the functionality of the cropping tool via the Rectangular Marquee tool but I am coming up short. I've also fished around on this board and elsewhere on the web for scripts that will allow me to do this automatically, again to no avail. Any suggestions?

 

This topic has been closed for replies.
Correct answer JJMack

A normal action can not be recorder to do what you want. The rectangle Marque tool if you set it to do a fixed aspect ratio of 50:28 you would need to drag out the selection centered and would  vary for different size images.   The crop tool can be set to crop to an aspect ration and initially it would be centered so all you would need to do is set the aspect ratio and commit the crop.   The problem is Action recorder records crop top left and bottom right corners location  for a crop. The  tool will constrain the side aspect ration  as you drag the tool around.  A centered 5:2.8 top left and bottom right corners would be different for different size documents. Scripting is required.

 

If you download My crafting Actions Package it contains a dozen or more Scripts I wrote for use in actions.  Two are Photoshop Plug-in that work  a lot like Adobe Plug-in script Fit Image.    I wrote them for Cropping  images to an aspect Ratio and settings print size.   These settings are recorded into the Action steps by the plug-ins when you record the action.  The First plug-in is Aspect Ratio Selection and the second Long Side Print length.    Aspect Ratio Selection can set a centered Aspect Ratio Selection  you cans crop the image to.  You specific two whole numbers in the Dialog.  It does not matter which order the numbers are set in the dialog  for the script will respect the orientation of your document.  Landscape Image will have Landscape selections set and portrait Portrait aspect ratio set.  For Cropping and changing orientation of an image would crop to much content the crop's composition would not be acceptable.  So if you had a 4:3 camera and the two numbers you set a 3 and 2 Landscaped selections will be 3:2 and Portrait set 2:3.   Long Side Print length records 1 number all the script does is set the correct  Print PPI to print the longer side the correct length.

 

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

Example
Download

 

 

For your Action the aspect ratio you would set would be 28 and 50 and 5 for the print size. That Action would look like this do not be concerned the the stare record pixels only the numeric values are used by the plug-in.  For the aspect ratio and the print side length in inches.

 

 

The Plug-in allow you to record in an action an Aspect Ratio Selection and center it relative to the document size.

2 replies

JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
February 6, 2020

A normal action can not be recorder to do what you want. The rectangle Marque tool if you set it to do a fixed aspect ratio of 50:28 you would need to drag out the selection centered and would  vary for different size images.   The crop tool can be set to crop to an aspect ration and initially it would be centered so all you would need to do is set the aspect ratio and commit the crop.   The problem is Action recorder records crop top left and bottom right corners location  for a crop. The  tool will constrain the side aspect ration  as you drag the tool around.  A centered 5:2.8 top left and bottom right corners would be different for different size documents. Scripting is required.

 

If you download My crafting Actions Package it contains a dozen or more Scripts I wrote for use in actions.  Two are Photoshop Plug-in that work  a lot like Adobe Plug-in script Fit Image.    I wrote them for Cropping  images to an aspect Ratio and settings print size.   These settings are recorded into the Action steps by the plug-ins when you record the action.  The First plug-in is Aspect Ratio Selection and the second Long Side Print length.    Aspect Ratio Selection can set a centered Aspect Ratio Selection  you cans crop the image to.  You specific two whole numbers in the Dialog.  It does not matter which order the numbers are set in the dialog  for the script will respect the orientation of your document.  Landscape Image will have Landscape selections set and portrait Portrait aspect ratio set.  For Cropping and changing orientation of an image would crop to much content the crop's composition would not be acceptable.  So if you had a 4:3 camera and the two numbers you set a 3 and 2 Landscaped selections will be 3:2 and Portrait set 2:3.   Long Side Print length records 1 number all the script does is set the correct  Print PPI to print the longer side the correct length.

 

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

Example
Download

 

 

For your Action the aspect ratio you would set would be 28 and 50 and 5 for the print size. That Action would look like this do not be concerned the the stare record pixels only the numeric values are used by the plug-in.  For the aspect ratio and the print side length in inches.

 

 

The Plug-in allow you to record in an action an Aspect Ratio Selection and center it relative to the document size.

JJMack
February 7, 2020

Thank you so much for your help! This worked. I appreciate your kindness in taking the time in offering me assistance in this and with you sharing your scripts with the rest of the community. You've helped me through a lot of frustration.

Participant
October 17, 2023

These are just what I need!

Does anyone have these scripts available to download? It seems the links are no longer working.

Chuck Uebele
Community Expert
Community Expert
February 6, 2020

Either turn on the dialog box, so you can adjust it, or use a script to get the proper dimension of the image for the crop.