PHP Resize image down and crop using imagemagick
- by mr12086
I'm trying to downsize image uploaded by users at the time of upload.
This is no problem but I want to get specific with sizes now.
I'm looking for some advice on an algorithm im struggling to produce that will take any shape image - square or rectangle of any widths/heights and downsize it.
This image needs to be downsized to a target box size (this changes but is stored in a variable)..
So it needs to downsize the image so that both the width and height are larger than the width and height of the target maintaining aspect ratio. but only just..
The target size will be used to crop the image so there is no white space around the edges etc.
I'm looking for just the algorithm behind creating the correct resize based on different dimension images - I can handle the cropping, even resizing in most cases but it fails in a few so i'm reaching out.
I'm not really asking for PHP code more pseudo. Either is fine obviously.
Thanks Kindly.