note 68231 added to function.imagejpeg

From: Date: Wed, 19 Jul 2006 03:47:50 +0000
Subject: note 68231 added to function.imagejpeg
Groups: php.notes 
Request: Send a blank email to php-notes+get-114907@lists.php.net to get a copy of this message
With regard to chris.calo's code: // The following block retrieves the source file. It assumes the filename extensions match the file's format. if ( strpos($source_file,".gif") ) { $img_source = imagecreatefromgif($source_file); } if ( (strpos($source_file,".jpg")) || (strpos($source_file,".jpeg")) ) ... etc. It assumes more than that, namely that the filename does not contain the strings '.gif', '.jpg', '.jpeg', '.bmp', or '.png' *anywhere* in the string. Some valid files with special filenames could break this; for example, a file named "used.to.be.a.png.file.gif" would cause this script to attempt to load the file as a PNG. Obviously this is a rare case, but the issue could be easily avoided by using "else ifs" (uses less CPU time) or checking that the extension abuts the end of the string or both. That said, the whole business could be avoided if PHP didn't clutter the namespace with different functions to do the same thing with different image formats. Ick. ---- Server IP: 64.71.164.2 Probable Submitter: 216.105.216.173 ---- 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/68231 Del: integrated -- http://master.php.net/note/delete/68231/integrated Del: useless -- http://master.php.net/note/delete/68231/useless Del: bad code -- http://master.php.net/note/delete/68231/bad+code Del: spam -- http://master.php.net/note/delete/68231/spam Del: non-english -- http://master.php.net/note/delete/68231/non-english Del: in docs -- http://master.php.net/note/delete/68231/in+docs Del: other reasons-- http://master.php.net/note/delete/68231 Reject -- http://master.php.net/note/reject/68231 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114907) next »