I’m trying to figure out how imgur.com is building their gallery (the one on the homepage to the right).
My problem is that I would like to create a thumbnail gallery from the images I have, but I want the width/height ratio to be correct so the image would not look weird.
So I can’t just take the uploaded image and change the height and width to 100px/100px as the ratio differs.
Do they crop the image, then create a thumbnail? How do they crop it? How do they set the crop ratio?
Thanks,
Calculate the thumbnail size…
http://www.php.net/manual/en/function.getimagesize.php
Alternatively, if you’d like to crop the image, use some PHP library. I’d recommend WigeImage. Its docs are well written, and it offers easy cropping, resizing, mirroring, rotating, etc. 🙂
Note that WideImage and other image functions documented in PHP docs require GD extension installed on your server.