hdt
10-07-2006, 11:11 PM
At first when I saw these ISO's I thought it's a problem with my image editing program, but when I realize that the same image is read with the correct ISO in my desktop programs (not only the one I edit the image with), I started digging into why the exifer is reading some ISO information incorrectly.
Long story short I learned a little about php and exif reading (I'm a programmer but didn't really know much about both), and I believe I've found a fix for this issue.
EXIFER sometimes reads the exif information as a 4 byte data, and sometimes as a 2 byte data, and when it's reading it as a 4 byte data it has the iso information twice in it. I can't really explain why since I didn't really dig into that part when fixing it, but focused on 'fixing' the 4 byte data instead.
So for example, as a 2 byte data, ISO '100' is :
0x00000064 (hex).
In images where iexifer's reading it as a 4 byte data, it has this data:
0x00640064
And of course, 0x00640064 in hex translates to... 65553700 in decimal. (ISO 200 -> 0x00C800C8 -> 13107400, etc)
My solution is to do this in line 397 of exif.php, last line in this snippet (in formatData method):
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
$data = bin2hex($data);
if($intel==1) $data = intel2Moto($data);
if($intel==0 && ($type=="USHORT" || $type=="SSHORT")) $data = substr($data,0,4);
$data=hexdec($data);
if ($tag="8827") $data=65535&$data; //mask 2 bytes for ISO rating
(Mask ISO data with 0x0000FFFF)
I've tested this with both images that were read correctly and incorrectly previously and looks like it worked.
Anyway, I thought I'd share this and my explanation (because I may not be 100% correct, since like I said, before I started I didn't really know much about php and reading EXIF).
Long story short I learned a little about php and exif reading (I'm a programmer but didn't really know much about both), and I believe I've found a fix for this issue.
EXIFER sometimes reads the exif information as a 4 byte data, and sometimes as a 2 byte data, and when it's reading it as a 4 byte data it has the iso information twice in it. I can't really explain why since I didn't really dig into that part when fixing it, but focused on 'fixing' the 4 byte data instead.
So for example, as a 2 byte data, ISO '100' is :
0x00000064 (hex).
In images where iexifer's reading it as a 4 byte data, it has this data:
0x00640064
And of course, 0x00640064 in hex translates to... 65553700 in decimal. (ISO 200 -> 0x00C800C8 -> 13107400, etc)
My solution is to do this in line 397 of exif.php, last line in this snippet (in formatData method):
} else if($type=="USHORT" || $type=="SSHORT" || $type=="ULONG" || $type=="SLONG" || $type=="FLOAT" || $type=="DOUBLE") {
$data = bin2hex($data);
if($intel==1) $data = intel2Moto($data);
if($intel==0 && ($type=="USHORT" || $type=="SSHORT")) $data = substr($data,0,4);
$data=hexdec($data);
if ($tag="8827") $data=65535&$data; //mask 2 bytes for ISO rating
(Mask ISO data with 0x0000FFFF)
I've tested this with both images that were read correctly and incorrectly previously and looks like it worked.
Anyway, I thought I'd share this and my explanation (because I may not be 100% correct, since like I said, before I started I didn't really know much about php and reading EXIF).