Resizing images to make them look good smaller

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pinehead18
Forum Contributor
Posts: 329
Joined: Thu Jul 31, 2003 9:20 pm

Resizing images to make them look good smaller

Post by pinehead18 »

Ok, so i have a site where you can upload pretty much any size image. However, i write a script that pulls from random images and i just said "width and height". this makes the images look like crap.

How can i make it so it resizes to the correct size so it doesn't look like crap?


Thanks
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Use getimagesize http://www.php.net/manual/en/function.getimagesize.php

Then calculate the ratio by defining max height and width and resample the image with http://www.php.net/manual/en/function.i ... ampled.php
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Use getimagesize() during display or imagecopyresampled() after the upload.
Post Reply