Problem when scaling Jpeg images with libgd
| From: | Mattias Jönsson | Date: | Thu, 20 May 2004 10:49:45 +0000 |
| Subject: | Problem when scaling Jpeg images with libgd | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-186570@lists.php.net to get a copy of this message | ||
Hello,
I have a problem when im trying to scale an jpeg image with libgd
my function lookes like this:
function image_resize_jpeg( $img, $w)
{
$image = imagecreatefromjpeg($img);
$img_info = getimagesize ($img);
$orig_height = $img_info[1]; //source hieght from $img_info
$orig_width = $img_info[0]; //source width from $img_info
if ($orig_width > $w) {
$h = ($w * $orig_height) / $orig_width;
$thumb = imagecreate($w, $h);
imagecopyresized($thumb, $image, 0, 0, 0, 0, $w, $h, $orig_width, $orig_height);
imagejpeg($thumb, $img, 95);
}
}
To illustrate:
Original image: http://www.thcca.com/~offson/test.jpg
scaled image: http://www.thcca.com/~offson/test_thumb.jpg
Does anyone have any suggestion what i can do?
_________________________________________________________________
Lättare att hitta drömresan med MSN Resor http://www.msn.se/resor/