note 62244 added to function.imagecreatefromstring

From: Date: Thu, 23 Feb 2006 05:22:31 +0000
Subject: note 62244 added to function.imagecreatefromstring
Groups: php.notes 
Request: Send a blank email to php-notes+get-104265@lists.php.net to get a copy of this message
I run a blogging site at http://www.elmwoodstrip.org where people are posting with all kinds of phones. I know a lot of people have been having trouble using images from the Sprint PPC6700 with GD. The jpeg library always thows an error about 16 bytes of extraneous data. I decided to poke around in a hex editor and found those extraneous bytes occur right at the end of the exif data and consist of the following hex string \x00\x10\x4A\x46\x49\x46\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00 By removing this extraneous data, images can easily be manipulated by GD and the EXIF extension as a normal images. This also removes any problems using the images with GIMP which must rely on the same jpeg libraries. Here is a function that will check to see if an image is from the PPC6700 and then remove the extraneous data for you. The result can successully be used with imagecreatefromstring function checkFixPPC6700($orig){ //get the file contents $data = file_get_contents($orig); //if its a PPC 6700 image cut out the extraneous 16 bits if(strstr($data, "\x41\x70\x61\x63\x68\x65\x00\x48")){ $bad_data = "\x00\x10\x4A\x46\x49\x46\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00"; return substr_replace($data, "", strpos($data, $bad_data), strlen($bad_data)); } else { //if not from a PPC 6700 return data unaltered return $data; } } ---- Server IP: 216.194.113.175 Probable Submitter: 24.51.38.20 ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefromstring.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+62244 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+62244&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+62244&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+62244&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+62244&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+62244&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+62244&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+62244&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+62244&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104265) next »