note 68333 added to function.imagejpeg

From: Date: Sun, 23 Jul 2006 17:55:06 +0000
Subject: note 68333 added to function.imagejpeg
Groups: php.notes 
Request: Send a blank email to php-notes+get-115062@lists.php.net to get a copy of this message
Thanks to Chris dot Calo for the thumbnail snippet. The file type issue is easily resolved by getting the type from the file with getimagesize, and you can handle unsupported types at that stage too. Thus: list($img_width,$img_height, $type) = getimagesize($source_file); // Get the original dimentions if ($type != 1 && $type != 2 && $type != 3 && $type != 15) { die("Your file is not a supported format"); } ...and then later check the type again to open the image correctly: if ( $type == 1 ) { $img_source = imagecreatefromgif($source_file); } else if ( $type == 2 ) { $img_source = imagecreatefromjpeg($source_file); } else if ( $type == 3 ) { $img_source = imagecreatefrompng($source_file); } else if ( $type == 15 ) { $img_source = imagecreatefromwbmp($source_file); } ---- Server IP: 85.116.0.130 Probable Submitter: 82.40.190.68 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.imagejpeg.php Edit -- http://master.php.net/note/edit/68333 Del: integrated -- http://master.php.net/note/delete/68333/integrated Del: useless -- http://master.php.net/note/delete/68333/useless Del: bad code -- http://master.php.net/note/delete/68333/bad+code Del: spam -- http://master.php.net/note/delete/68333/spam Del: non-english -- http://master.php.net/note/delete/68333/non-english Del: in docs -- http://master.php.net/note/delete/68333/in+docs Del: other reasons-- http://master.php.net/note/delete/68333 Reject -- http://master.php.net/note/reject/68333 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#115062) next »