note 72619 added to function.imagecreatefromjpeg

From: Date: Fri, 26 Jan 2007 12:41:17 +0000
Subject: note 72619 added to function.imagecreatefromjpeg
Groups: php.notes 
Request: Send a blank email to php-notes+get-122222@lists.php.net to get a copy of this message
When i run following function dis function terminates at the 13th line where is says: $img = @imagecreatefromjpeg($image_path); no other code of the script gets executed. can anyone help me. i use PHP5 with GD lib support function convertLQ($image_path) { ClearStatCache(); $file = basename($image_path); $dirname = dirname ($image_path); // set save path + name $save_path = $dirname.'/LQ/'.$file; // Load image $img = null; $ext = strtolower(end(explode('.', $image_path))); $image_path = htmlentities($image_path); if ($ext == 'jpg' || $ext == 'jpeg') { $img = @imagecreatefromjpeg($image_path); } else if ($ext == 'png') { $img = @imagecreatefrompng($image_path); } else if ($ext == 'gif') { $img = @imagecreatefromgif($image_path); } // If an image was successfully loaded, test the image for size if ($img) { // Get image size and scale ratio $width = imagesx($img); $height = imagesy($img); $scale = maxHeightLQ/$height; // If the image is larger than the max shrink it if ($scale < 1) { $new_width = floor($scale*$width); $new_height = floor($scale*$height); // Create a new temporary image $tmp_img = imagecreatetruecolor($new_width, $new_height); // Copy and resize old image into new image imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagedestroy($img); $img = $tmp_img; } } // Create error image if necessary if (!$img) { $img = imagecreate(witdhErrorImage,heightErrorImage); $backgroundcolor = imagecolorallocate($img,70,70,70); $c = imagecolorallocate($img,70,70,70); $red = ImageColorAllocate($img,255,0,0); imageline($img,0,0,witdhErrorImage,heightErrorImage,$red); imageline($img,witdhErrorImage,0,0,heightErrorImage,$red); imagejpeg($img,$save_path,85); imagedestroy($img); return false; } // Save the image if ($ext == 'jpg' || $ext == 'jpeg') { imagejpeg($img,$save_path,85); } else if ($ext == 'png') { imagePng($img,$save_path); } else if ($ext == 'gif') { ImageGif($img,$save_path); } else { imagejpeg($img,$save_path,85); } imagedestroy($img); return true; } ---- Server IP: 194.109.193.94 Probable Submitter: 194.151.106.227 (proxied: 1.1 ISA01) ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefromjpeg.php Edit -- https://master.php.net/note/edit/72619 Del: integrated -- https://master.php.net/note/delete/72619/integrated Del: useless -- https://master.php.net/note/delete/72619/useless Del: bad code -- https://master.php.net/note/delete/72619/bad+code Del: spam -- https://master.php.net/note/delete/72619/spam Del: non-english -- https://master.php.net/note/delete/72619/non-english Del: in docs -- https://master.php.net/note/delete/72619/in+docs Del: other reasons-- https://master.php.net/note/delete/72619 Reject -- https://master.php.net/note/reject/72619 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122222) next »