04-10-2008, 07:00 PM
|
#4 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
easy really, here the script i use:
PHP Code:
function resizeImage($originalImage,$toWidth,$toHeight,$dest_img) { list($width, $height) = getimagesize($originalImage); $xscale=$width/$toWidth; $yscale=$height/$toHeight;
if ($yscale>$xscale) { $new_width = round($width * (1/$yscale)); $new_height = round($height * (1/$yscale)); } else { $new_width = round($width * (1/$xscale)); $new_height = round($height * (1/$xscale)); } $imageResized = imagecreatetruecolor($new_width, $new_height); $imageTmp = imagecreatefromjpeg ($originalImage); imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
imagejpeg($imageResized, $dest_img); }
resizeImage('test1.jpg', 400, 400, 'test_res2222222.jpg');
I have used this in the past, should be easy for you to modify, it takes into account image orientation (i.e. landscape/portrait) and scales accoringly. It olny accepts jpegs atm but like i say you its easy to customize it with the correct image format function. the php manual is useful here:
PHP: Image - Manual
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|