Skip to main content
Participant
April 23, 2020
Question

Batch resizing photos of different dimensions

  • April 23, 2020
  • 3 replies
  • 3320 views

I have hundreds of photos that I want to all be square in order to look more clean when presented on a website. These photos have different dimensions, some more square and some more rectangular. I've been creating a new document of the correct square ppi dimensions and have been just importing one photo at a time onto this blank template. Photoshop automatically fits the image perfectly so there is proper white space around the photo just as I need. However like I said there are hundreds of photos. Is there a way to do this in a batch action? I've looked into batch resizing but that seems like it wouldn't help as these photos are all different sizes and I need to add that white square as their background. So it's not so much of a resizing issue, but creating many new documents of the same size all at once and placing all of these photos on the new documents individually. If this isn't possible, that's fine I just was looking for a definite answer as to if I can do this or not because I cannot seem to find an answer online anywhere.  

This topic has been closed for replies.

3 replies

Stephen Marsh
Community Expert
Community Expert
April 24, 2020

The following script will resize the canvas to square based on the longest edge, effectively "letterboxing" a landscape image or  the opposite on a portrait image. The canvas extension colour is white. You can remove the // comment double slashes from the code to enable resizing, then change the dimensions from 1020,1020 to whatever pixel size you require.

 

 

/* https://forums.adobe.com/message/6424562#6424562 */

#target photoshop

// Save the current ruler units and set to pixels
var savedRuler = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
 
var backgroundC = new SolidColor();
    backgroundC.rgb.red = 255;
    backgroundC.rgb.green = 255;
    backgroundC.rgb.blue = 255;
    backgroundColor = backgroundC;
   
var doc = app.activeDocument;
 
doc.resizeCanvas(Math.max(doc.width,doc.height),Math.max(doc.width,doc.height))

// Uncomment the line below to fit to a 1020px square rather than longest edge
//doc.resizeImage(1020,1020) 

// Restore the ruler units
app.preferences.rulerUnits = savedRuler;

 

 

 

JJMack
Community Expert
Community Expert
April 24, 2020

Resize the canvas to the smaller side will crop the image square.  Also content aware fill can fill the added white canvas above.  I prefer crop.

JJMack
Stephen Marsh
Community Expert
Community Expert
April 24, 2020

Agreed JJMack, for anybody wishing to try this, just change both instances of:

 

Math.max

 to

 

Math.min

 

JJMack
Community Expert
Community Expert
April 24, 2020

Actions can not handle sizing of  document well when they have various document Aspect Ratio and sizes.  To size them to a common aspect ratio and size you need to use Photoshop scripting. A  script can crop the images to the output image Aspect Ratio and resample or set the print resolution of the crop to the output image size  so it will have the correct number of pixels and the correct print resolution.

 

I wrote two Photoshop Plug-In Script Aspect Ratio Slection "AspectRatioSelection.jsx" and Long Side Print Length  "LongSidePrintLength.jsx" You can use in action to enable you to create action that will do what you want to do. They are in my crafting Action Package. The Resolution is changed for the crop the image is not resampled via the plug-in after the aspect ration selection crop is made.

 

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

Example
Download

JJMack
Derek Cross
Community Expert
Community Expert
April 23, 2020

Have a look at the Photoshop Image Processor – File > Scripts > Image Processor

JJMack
Community Expert
Community Expert
April 24, 2020

Image Processor will not change a images aspect ratio to square. The image's aspect ration is preserved. The image is resized via interpolation fit with within the square size you set.

JJMack