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;
}
}