Use php to get a photo in the right proportions
Posted on 2011-09-04
I have a folder full of .jpg files of all kinds of random dimensions and sizes. I have used php for manipulating images but it has been a while.
I wish to print them all to 8"x12" paper and have nothing cropped or stretched from the original.
What I am currently doing is manually adding black bars to meet the correct dimensions.
Since I'm printing to 8"x12" the ratio is 1/1.5 or 0.667
So a photo coming in at 3000x4000 will finalize at 3000x4500 with black on top & bottom of 3000x250
A picture coming in at 2500x10000 will finalize at 6666x10000 with black bars on right & left of 2083x10000
Hopefully I'm being clear. The incoming photo will be of varying sizes, both landscape & portrait. They will all print to 8"x12" or 12"x8" with no stretching or cropping.