Batch crop to certain ratios
Hello,
I have over 2000 photos that I want to crop to certain ratio depending on the closest defined ratio.
The ratios I need are 1:1 and 7:5 and 1:3 They can be both portrait and landscape
Examples,
Original dimensions (px) => Cropped dimensions (px)
100x110 => 100x100
159x50 => 150x50
42x120 => 40x120
How can I do that?
I have found this code by @SuperMerlin that I think can be adapted to do this. After checking the image dimensions instead of moving it should crop the image.
Problem is I have no idea how to modify the script! Any help would be greatly appreciated.
*Bonus point 🙂 if the crop can be "Smart" in a way to detect the important object in the image that would be amazing.
#target bridge
if( BridgeTalk.appName == "bridge" ) {
sortPics = new MenuElement("command", "Sort Landscape - Portrait - Square Pics", "at the end of Tools");
}
sortPics.onSelect = function () {
var sels = app.document.selections;
if(sels.length < 1) return;
var origFolder = decodeURI(app.document.thumbnail.spec);
var portFolder = Folder(origFolder + "/Portrait");
var landFolder = Folder(origFolder + "/Landscape");
var sqrFolder = Folder(origFolder + "/Square");
if(!portFolder.exists) portFolder.create();
if(!landFolder.exists) landFolder.create();
if(!sqrFolder.exists) sqrFolder.create();
app.synchronousMode = true;
for (var s =0;s< sels.length;s++){
var Thumb = new Thumbnail(sels[s]);
var Rotation = Thumb.rotation;
var Width = Thumb.core.quickMetadata.width * 1;
var Height = Thumb.core.quickMetadata.height *1;
if(Width ==0 || Height == 0) continue;
if(Width > Height && Rotation == 0) Thumb.moveTo(landFolder);
if(Width < Height && Rotation == 0) Thumb.moveTo(portFolder);
if(Width > Height && Rotation != 0) Thumb.moveTo(portFolder);
if(Width < Height && Rotation != 0) Thumb.moveTo(landFolder);
if(Width == Height) Thumb.moveTo(sqrFolder);
}
app.synchronousMode = false;
};*Bonus point 🙂 I am not sure if IM can do this, but if it can do "Smart" cropping and detect the important part of the image that would be great
