note 72619 deleted from function.imagecreatefromjpeg by felipe

From: Date: Sat, 24 May 2008 18:47:17 +0000
Subject: note 72619 deleted from function.imagecreatefromjpeg by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139705@lists.php.net to get a copy of this message
Note Submitter: henk_vd_bosch at planet dot nl ---- 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; }

« previous php.notes (#139705) next »