note 62351 added to function.imagecreatefromstring
| From: | junkmail at pmobl dot com | Date: | Sat, 25 Feb 2006 22:37:06 +0000 |
| Subject: | note 62351 added to function.imagecreatefromstring | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104437@lists.php.net to get a copy of this message | ||
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.
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
Author: Paul Visco
IM: paulsidekick
Created: 2-12-06
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")){
//this next line can all be one string I split it up so the form on php.net would accept it
$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: 64.71.164.2
Probable Submitter: 24.51.38.20
----
Manual Page -- http://www.php.net/manual/en/function.imagecreatefromstring.php
Edit -- http://master.php.net/note/edit/62351
Del: integrated -- http://master.php.net/note/delete/62351/integrated
Del: useless -- http://master.php.net/note/delete/62351/useless
Del: bad code -- http://master.php.net/note/delete/62351/bad+code
Del: spam -- http://master.php.net/note/delete/62351/spam
Del: non-english -- http://master.php.net/note/delete/62351/non-english
Del: in docs -- http://master.php.net/note/delete/62351/in+docs
Reject -- http://master.php.net/reject/62351&report=yes
Search -- http://master.php.net/manage/user-notes.php