RE: [PHP] picture help
| From: | (Edward Peloke) | Date: | Wed, 18 Jun 2003 21:05:46 +0000 |
| Subject: | RE: [PHP] picture help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152072@lists.php.net to get a copy of this message | ||
thanks, I tried and it doesn't help. For some reason some of the pictures I
upload look fine and some look bad no matter if I use imagecopyresampled or
resized
-----Original Message-----
From: Lars Torben Wilson [mailto:torben@php.net]
Sent: Wednesday, June 18, 2003 4:49 PM
To: Edward Peloke
Cc: Php-General@Lists. Php. Net
Subject: Re: [PHP] picture help
On Wed, 2003-06-18 at 13:39, Edward Peloke wrote:
> Hello all, I have this code that takes an image sent from a form and
resizes
> it for a thumbnail and for display, the problem is the pictures look nice
> until this does the resizing, then the quality is horrible...can I fix it?
>
> Thanks,
> Eddie
If you have GD version 2.0.1 or later and PHP 4.0.6 or later, try using
imagecopyresampled() instead of imagecopyresized(). You may get better
results.
Good luck,
Torben
> <?
> if(!empty($myimage)){
> $id=$HTTP_GET_VARS['id'];
> $imgname="image_".$id.".jpg";
> copy($myimage,$imgname);
> unlink($myimage);
> function thumbnail($i,$nw,$p,$nn) {
> $img=imagecreatefromjpeg("$i");
> $ow=imagesx($img);
> $oh=imagesy($img);
> $scale=$nw/$ow;
> $nh=ceil($oh*$scale);
> $newimg=imagecreate($nw,$nh);
> imagecopyresized($newimg,$img,0,0,0,0,$nw,$nh,$ow,$oh);
> imagejpeg($newimg, $nn);
> return true;
> }
>
> #thumbnail(filetouse,newwidth,newpath,newname);
> thumbnail($imgname,100,"/imges/","t_".$imgname);
> thumbnail($imgname,250,"/imges/",$imgname);
>
> }
> ?>
--
Torben Wilson <torben@php.net> +1.604.709.0506
http://www.thebuttlesschaps.com http://www.inflatableeye.com
http://www.hybrid17.com http://www.themainonmain.com
-----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php