PDA

View Full Version : EXIFER bug (iso 6553700, 13107400, ...)


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).

Connie
10-08-2006, 07:18 AM
that is a good point.... thanks!

I will add this as info to our todo-list! thanks again!

GeoS
10-08-2006, 09:51 PM
IMHO it should be:
if ($tag == "8827") $data=65535&$data; //mask 2 bytes for ISO rating

hdt
10-09-2006, 10:25 PM
Haha yes absolutely :D, good catch. I made another typo there also.. tag should be 8827, not 8227...
So make that

if ($tag == "8827") $data=65535&$data; //mask 2 bytes for ISO rating

I also just noticed that in Opera browser, which shows EXIF info when you right click->Image properties, it shows the double ISO data separated by comma (ISO speed rating: 100, 100). So there's probably a purpose for the other ISO data field in the EXIF which someone with deeper EXIF knowledge can probably explain...

dhdesign
03-25-2007, 03:19 AM
Thanks for this solution! Was able to resolve one issue I've been having this evening with exif data.