Re: image resize looks horrible..
| From: | Marek Kilimajer | Date: | Mon, 07 Jun 2004 18:37:21 +0000 |
| Subject: | Re: image resize looks horrible.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-187825@lists.php.net to get a copy of this message | ||
Is $gd2 set right?
Edward Peloke wrote:
Any ideas as to how I can fix this function??? -----Original Message----- From: Edward Peloke [mailto:epeloke@echoman.com] Sent: Thursday, June 03, 2004 4:18 PM To: Php-General Subject: [PHP] image resize looks horrible.. I am using the below function which does seem to resize the image yet the colors in the resized image look horrible. How can I resize the image yet keep the colors in tact? Thanks, Eddie Justin-I tried your code but it didn't seem to do anything...I will just use this function if the color will work. function createthumb($name,$filename,$new_w,$new_h){global $gd2; $system=explode(".",$name); $src_img=imagecreatefromjpeg($name); $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } if ($gd2==""){ $dst_img=ImageCreate($thumb_w,$thumb_h);imagecopyresized($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);}else{ $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y );} if (preg_match("/png/",$system[1])){ imagepng($dst_img,$filename); } else { imagejpeg($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($src_img);}