How do you resize images by batch on photoshop where it scales based on the smaller dimension

StackOverflow https://stackoverflow.com/questions/23185254

  •  06-07-2023
  •  | 
  •  

Question

I dont really know how to explain this, but..

How do you resize images by batch on photoshop where it scales based on the smaller dimension.

So basically, i want images to resize to 200x200 and I want the image to take the smaller dimension, center the image, then crop the excess of the bigger dimension.

Is there a way to do this?

I hope I make sense.

Was it helpful?

Solution

This script will resize the image so that the smallest dimension will become 200 and then crop it to 200 x 200

app.preferences.rulerUnits = Units.PIXELS;

// call the source document
var srcDoc = app.activeDocument;
var imageWidth = srcDoc.width.value;
var imageHeight = srcDoc.height.value;
var ts = 200;

if (imageHeight < imageWidth)
{
  // landscape
  var h = 200;
  var w = Math.floor((imageWidth/imageHeight)*h);
}
else
{
  // portrait
  var w = 200;
  var h = Math.floor((imageHeight/imageWidth)*w);
}
srcDoc.resizeImage(w, h, 72, ResampleMethod.BICUBIC);

//crop it in the centre
app.activeDocument.resizeCanvas(ts, ts, AnchorPosition.MIDDLECENTER);

OTHER TIPS

You may need to use Actions and Automate in order to accomplish this. Here is a link to a tutorial:

http://www.digitalartsonline.co.uk/tutorials/photoshop/how-resize-multiple-images-in-photoshop/

Go to Image > Image Size.

This will bring up the Image Size dialog box, as shown below:

photoshop

see documentation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top