Copy link to clipboard
Copied
Hi folks,
I would like to resize a ton of pictures, which have a lot of different aspect ratios.
The pictures have to be at least 2560 px in height and 1440 px in width.
Do you have a solution to solve this problem?
Thank you and best regards,
Sebastian
Try this:
#target photoshop
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var wFactor = parseFloat(1440/doc.width)
var hFactor = parseFloat(2560/doc.height);
if(wFactor>hFactor){doc.resizeImage(1440,undefined,undefined,ResampleMethod.BICUBIC)}
else{doc.resizeImage(undefined,2560,undefined,ResampleMethod.BICUBIC)}
Copy link to clipboard
Copied
What is the max size? Do you want the photos just have at least one side the min size?
Copy link to clipboard
Copied
There is no maximum size and I would like both sides to have the minimum size.
So for me it would be okay if the height would be 1440 and the width e.g. 2890 px.
Copy link to clipboard
Copied
Adobe Photoshop has two scripts you can use to fit your images within some size area. When a image is resized its aspect ration will not change so its content will not distort. The script name is "Fit Image.jsx" You can record it an action you can batch your images with. menu File>Automate>Fit Image... the script will record the max with and height you set into the action step. Or you can use menu File>Scripts>Images Processor... to batch your images and set the max with and height into the Images processor's dialog. The images processor will use Fit Image to resized your images.
You set the max size a side can be. The image Aspect ratio will be maintained. Be fitted to the width or height or fix exactly if the image has that aspect ratio.
You could instead distort your images to that exact size if you want to with content aware resize.
Copy link to clipboard
Copied
This method is not working for my task.
Because I would like to set the minimum.
Would it be possible to write an action or a script which includes these commands:
1. Resize Image by Height to 1440 px
2. Check the Width -> if it is smaller than 2560 px go back one step and resize the picture by its Height to 2560 px
Copy link to clipboard
Copied
sebastians78614123 wrote
This method is not working for my task.
Because I would like to set the minimum.
Would it be possible to write an action or a script which includes these commands:
1. Resize Image by Height to 1440 px
2. Check the Width -> if it is smaller than 2560 px go back one step and resize the picture by its Height to 2560 px
There is a problem with your understanding of resizing an image. if you do not want your image to be distorted the resized image must have the same Aspect Ratio as the original image for the are relative to each other. The resized image sides will have the same Aspect Ratio as the original. If the two setting you set do not match your images aspect ratio the image would need to be distorted to that size via content aware resize. The both sides will be your minimum sizes some of the image content will be distorted.
If the Aspect Ratio does not match your two setting if you resize one size to your minimum value the other side will be larder or smaller than your minimum. would 1Px be ok or 50000 px be ok. You can set size you want a side to be and resize to that side size and let the oother side fall where it will. However that dose not work well for odd aspect ratio images. You wind up with images that are usually that are to high or to wide or to short or to narrow.
Fit Image is what you want to use it resize an image to fit with in some size area the images aspect ratio will determine if the image should be resized to the area width or height or be an exact fit.
Copy link to clipboard
Copied
Try this:
#target photoshop
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var wFactor = parseFloat(1440/doc.width)
var hFactor = parseFloat(2560/doc.height);
if(wFactor>hFactor){doc.resizeImage(1440,undefined,undefined,ResampleMethod.BICUBIC)}
else{doc.resizeImage(undefined,2560,undefined,ResampleMethod.BICUBIC)}
Copy link to clipboard
Copied
Maybe it makes sense to add an additional query: if the size 1440 or 2560 px as minimum has.
Copy link to clipboard
Copied
This script is perfect!
Thanks a lot and sorry for the late response.