note 80533 added to function.imagejpeg

From: Date: Mon, 21 Jan 2008 05:20:42 +0000
Subject: note 80533 added to function.imagejpeg
Groups: php.notes 
Request: Send a blank email to php-notes+get-135275@lists.php.net to get a copy of this message
When using ImageJpeg ($img, "", $qlty) or any other Image*() command, with direct output to browser, BE ABSOLUTELY CERTAIN that your php file does not contain any \r, \n, or white spaces before the <? and after the ?> signs. This should always kept in mind, not only for the file you are executing BUT ALSO FOR ALL THE INCLUDES called during the file execution! I got totally crazy about this, for a whole weekend :( My php editor did not correctly display a \n sign, as I was locally using a different charset/OS. example <? include ("/usr/www.example.com/inc/function.inc.php"); include ("/usr/www.example.com/inc/function.common.php"); connect_db0 (); $admin_cookie = ckadmin_cookie (); ... $img = file_get_contents ($path.$_GET['src']); $im = imagecreatefromstring ($img); header ("Content-Type: image/jpeg"); imageJPEG ($im); imageDestroy ($im); ... ?> If any of the included files, for any reason, prints an error message (or simply a warning) or has any white spaces/return/new line chars before "<?" or after the ">?" signs, the result will be a broken image! Even looking inside the defective image, it will be quite difficult to notice the unwanted characters, especially if you are using something like the windows' notepad... X( If nothing is found, with the file/php editors, and you are not sure about your charset compatibility, I suggest to try to edit directly the files on the server, if possible, and search for all unwanted chars. ;) ---- Server IP: 80.241.173.254 Probable Submitter: 151.47.154.169 ---- Manual Page -- http://www.php.net/manual/en/function.imagejpeg.php Edit -- https://master.php.net/note/edit/80533 Del: integrated -- https://master.php.net/note/delete/80533/integrated Del: useless -- https://master.php.net/note/delete/80533/useless Del: bad code -- https://master.php.net/note/delete/80533/bad+code Del: spam -- https://master.php.net/note/delete/80533/spam Del: non-english -- https://master.php.net/note/delete/80533/non-english Del: in docs -- https://master.php.net/note/delete/80533/in+docs Del: other reasons-- https://master.php.net/note/delete/80533 Reject -- https://master.php.net/note/reject/80533 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135275) next »