Hello, could someone set me on the right path for Windows Photoshop scripting (I assume this would require a script)...
My objective is to iterate thru a folder of images, center crop the images based on height/width ratio variables, and save the images within the same folder. I've detailed the 2 IF statements conditionals below-
On all the calculations, round up to the nearest pixel.
Code:
Variables:
WidthRatio = 4
HeightRatio = 3
-- Image's aspect ratio is greater than the desired ratio
-- so crop out left and right areas of the Image
If (Image's width / Image's height) > (WidthRatio/ HeightRatio)
Set selection
To: rectangle
Top: 0 px
Left: (Image's width - (Image's height * (WidthRatio/HeightRatio))) / 2 px
Bottom: (Image's height) px
Right: (Image's width + (Image's height * (WidthRatio/HeightRatio))) / 2 px
Crop
Save image
End If
-- Image's aspect ratio is less than the desired ratio
-- so crop out top and bottom areas of the Image
If (Image's width / Image's height) < (WidthRatio/ HeightRatio)
Set selection
To: rectangle
Top: (Image's height - (Image's width * (HeightRatio/WidthRatio))) / 2 px
Left: 0 px
Bottom: (Image's height + (Image's width * (HeightRatio/WidthRatio))) / 2 px
Right: (Image's width) px
Crop
Save image
End If
Thanks,
Dan