Forum Moderators: coopster

Message Too Old, No Replies

How to resize image with PHP code?

         

toplisek

12:35 pm on May 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would like to resize image from 2048x1536 to
width='269' height='202' with PHP language.
[/PHP]

I have some code like:
[PHP]
//set new height
$size = 150;
$src = imagecreatefromstring ($data);
$width = imagesx($src);
$height = imagesy($src);
$aspect_ratio = $height/$width;

//start resizing
if ($height <= $size)
{
$new_w = $width;
$new_h = $height;
}
else {
$new_h = $size;
$new_w = abs($new_h / $aspect_ratio);
}
[/PHP]

How to implement this as I'm new to this.Need help.

eelixduppy

12:57 pm on May 30, 2007 (gmt 0)



Look at the documentation for imagecopyresampled [php.net]. The examples show how to resize an image using that function. Try to write it first, and if you need further assistance, I'm sure someone here will be glad to assist you :)

Best of luck!