rc726c Posted January 5, 2009 Share Posted January 5, 2009 could someone tell me, whats wrong with this code at below?? it gets an error_log like this: [Wed Dec 10 02:58:05 2008] [error] [client 195.xxx.xx.32] PHP Warning: imagedestroy(): supplied argument is not a valid Image resource in /var/www/html/w/htdocs/online/duckula/fotolar/thumb.php on line 47, referer: http://www.site.com/ <? /* =================================== + yThumb Class + Author: Yunus Emre Yilmaz + http://yns.zaxaz.com/ythumb.yns =================================== */ class yThumb { // find extension of file function find_extension($file) { $array = explode('.',$file); $key = count($array) -1; $ext = $array[$key]; return $ext; } function thumb($image,$w,$h) { if($this->find_extension($image) == 'jpg') $image_data = imagecreatefromjpeg($image); if($this->find_extension($image) == 'gif') $image_data = imagecreatefromgif ($image); if($this->find_extension($image) == 'png') $image_data = imagecreatefrompng ($image); // Original width && height $width = imagesx($image_data); $height = imagesy($image_data); // Control width && and height if(@$w > 800 || @$h > 800) { $w= $width; $h= $height; } if(@empty($w)) $w = 400; if(@empty($h)) $h = 600; $new = imagecreatetruecolor($w, $h); imagecopyresampled($new, $image_data, 0, 0, 0, 0, $w, $h, $width, $height); // Finally, output.. if($this->find_extension($image) == 'jpg') $image_data = imagejpeg($new); if($this->find_extension($image) == 'gif') $image_data = imagegif ($new); if($this->find_extension($image) == 'png') $image_data = imagepng ($new); // Flush memory imagedestroy($image_data); // line 47 imagedestroy($new); } } $a = new yThumb(); $a->thumb($_GET["image"],@$_GET["w"],@$_GET["h"]); ?> Link to comment https://forums.phpfreaks.com/topic/139471-imagedestroy-problem/ Share on other sites More sharing options...
rc726c Posted January 5, 2009 Author Share Posted January 5, 2009 i changed the bottom part of the code like this. this time, it doesnt gets an error_log.. but it doesnt work too its not working // Finally, output.. $data = pathinfo($image); switch(strtolower($data['extension'])) { case 'gif': $image_data = imagegif($new); break; case 'png': $image_data = imagepng($new); break; case 'jpg': default: $image_data = imagejpeg($new); break; } if(isset($image_data)) { imagedestroy($image_data); imagedestroy($new); } else { die('Error processing thumbnail'); } Link to comment https://forums.phpfreaks.com/topic/139471-imagedestroy-problem/#findComment-729588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.