Skip to main content
Participant
February 19, 2024
Answered

Action or script to automatically make image square regardless of original size or orientation

  • February 19, 2024
  • 1 reply
  • 1869 views

Hi all, I 'm looking to hopefully find (preferred) or create (if needed) an action or script that will automatically determine what the longest side of an opened file is and then change the shorter side of the canvas to the same pixel dimension as the longest one was so the file ends up with a square aspect ratio. I want this to work regardless of the original pixel dimensions of the file, the action/script should not need that to make the file square. The reason I want it to work this way is because we have many images that are all over the map in size and I want them, at this point in time, to stay that way. I just need them to be square instead of portrait or landscape. Secondly any extra canvas that is created should be filled with white. Does this exist or is there a specific way to record the action? I have tried in vain to create one or find one and have exceeded my ability level. Thank you in advance for any insight!

Correct answer Stephen Marsh

@alimedi77729338 

 

You're welcome. Please mark the appropriate reply or replies as a correct answer to resolve the status of the discussion.

 

Searching for keywords of square or 1:1 does take some time! Most topics would likely be using fit image and canvas size as the requirement would be to normalise files to specific pixel dimensions. Using the rotated layer trick is less common, however, it's required in this case as you need variable dimensions based off each individual image. Without the rotated layer trick you would likely need a script for performing such logic.

1 reply

Stephen Marsh
Community Expert
Community Expert
February 19, 2024

Yes, an action can (mostly) do this, there's no need for a script unless you prefer one.

 

The original image is copied to a new layer and rotated 90 degrees and a reveal all step to expand the canvas. Then delete the rotated layer. There are other steps, but these are the key ones.

 

Various steps will depend on whether you only have flattened images, or layered images and whether you wish to flatten the result of layers or retain the layers.

 

EDIT: Original action modified and download link updated!

 

 

Action download:

https://www.dropbox.com/scl/fi/15uyh98xpqce58x114gk9/Resize-to-Square-with-White-BG.atn?rlkey=6edi3kc83q4f14onj4clo525y

 

P.S. There are many topics in the forum for creating square 1:1 ratio images.

 

Inspiring
March 23, 2025

Hi

This is really interesting and what i was looking for, but i cant stop it from making a white background, even after i edit the action fill to black. Any help appreciated. 

Stephen Marsh
Community Expert
Community Expert
March 24, 2025
quote

Hi

This is really interesting and what i was looking for, but i cant stop it from making a white background, even after i edit the action fill to black. Any help appreciated. 


By @simonbrattphotography

 

Record your action like this:

 

1) If there's a Background layer, start by unlocking it to become a standard layer capable of accepting transparency.

 

2) Ctrl/Cmd + J to dupe the layer

 

3) Edit > Transform > Rotate the layer 90°

 

4) Image > Reveal All

 

5) Delete the rotated layer as it has served it's purpose

 

6) Add a new solid fill layer in black

 

7a) Change it's blend mode to Lighten

 

or

 

7b) Move it to the bottom of the layer stack using Ctrl/Cmd + Shift [