function parseOlympus($block, &$result, $seek, $globalOffset) { if ($result['Endien'] == "Intel") { $intel = 1; } else { $intel = 0; } $model = $result['IFD0']['Model']; $place = 8; //current place $offset = 8; //Get number of tags (2 bytes) $num = bin2hex(substr($block, $place, 2)); $place += 2; if ($intel == 1) { $num = intel2Moto($num); } $result['SubIFD']['MakerNote']['MakerNoteNumTags'] = hexdec($num); //loop thru all tags Each field is 12 bytes for ($i = 0; $i < hexdec($num); $i++) { //2 byte tag $tag = bin2hex(substr($block, $place, 2)); $place += 2; if ($intel == 1) { $tag = intel2Moto($tag); } $tag_name = lookup_Olympus_tag($tag); //2 byte type $type = bin2hex(substr($block, $place, 2)); $place += 2; if ($intel == 1) { $type = intel2Moto($type); } lookup_type($type, $size); //4 byte count of number of data units $count = bin2hex(substr($block, $place, 4)); $place += 4; if ($intel == 1) { $count = intel2Moto($count); } $bytesofdata = $size * hexdec($count); //4 byte value of data or pointer to data $value = substr($block, $place, 4); $place += 4; if ($bytesofdata <= 4) { $data = $value; } else { $value = bin2hex($value); if ($intel == 1) { $value = intel2Moto($value); } $v = fseek($seek, $globalOffset + hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file if ($v == 0) { $data = fread($seek, $bytesofdata); } else { if ($v == -1) { $result['Errors'] = $result['Errors']++; } } } $formated_data = formatOlympusData($type, $tag, $intel, $data); if ($result['VerboseOutput'] == 1) { $result['SubIFD']['MakerNote'][$tag_name] = $formated_data; if ($type == "URATIONAL" || $type == "SRATIONAL" || $type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") { $data = bin2hex($data); if ($intel == 1) { $data = intel2Moto($data); } } $result['SubIFD']['MakerNote'][$tag_name . "_Verbose"]['RawData'] = $data; $result['SubIFD']['MakerNote'][$tag_name . "_Verbose"]['Type'] = $type; $result['SubIFD']['MakerNote'][$tag_name . "_Verbose"]['Bytes'] = $bytesofdata; } else { $result['SubIFD']['MakerNote'][$tag_name] = $formated_data; } } }
function parseOlympus($block, &$result, $seek, $globalOffset) { if ($result['Endien'] == "Intel") { $intel = 1; } else { $intel = 0; } $model = $result['IFD0']['Model']; // New header for new DSLRs - Check for it because the // number of bytes that count the IFD fields differ in each case. // Fixed by Zenphoto 2/24/08 $new = false; if (substr($block, 0, 8) == "OLYMPUS") { $new = true; } else { if (substr($block, 0, 7) == "OLYMP" || substr($block, 0, 7) == "OLYMP") { $new = false; } else { // Header does not match known Olympus headers. // This is not a valid OLYMPUS Makernote. return false; } } // Offset of IFD entry after Olympus header. $place = 8; $offset = 8; // Get number of tags (1 or 2 bytes, depending on New or Old makernote) $countfieldbits = $new ? 1 : 2; // New makernote repeats 1-byte value twice, so increment $place by 2 in either case. $num = bin2hex(substr($block, $place, $countfieldbits)); $place += 2; if ($intel == 1) { $num = intel2Moto($num); } $ntags = hexdec($num); $result['SubIFD']['MakerNote']['MakerNoteNumTags'] = $ntags; //loop thru all tags Each field is 12 bytes for ($i = 0; $i < $ntags; $i++) { //2 byte tag $tag = bin2hex(substr($block, $place, 2)); $place += 2; if ($intel == 1) { $tag = intel2Moto($tag); } $tag_name = lookup_Olympus_tag($tag); //2 byte type $type = bin2hex(substr($block, $place, 2)); $place += 2; if ($intel == 1) { $type = intel2Moto($type); } lookup_type($type, $size); //4 byte count of number of data units $count = bin2hex(substr($block, $place, 4)); $place += 4; if ($intel == 1) { $count = intel2Moto($count); } $bytesofdata = $size * hexdec($count); //4 byte value of data or pointer to data $value = substr($block, $place, 4); $place += 4; if ($bytesofdata <= 4) { $data = $value; } else { $value = bin2hex($value); if ($intel == 1) { $value = intel2Moto($value); } $v = fseek($seek, $globalOffset + hexdec($value)); //offsets are from TIFF header which is 12 bytes from the start of the file if (isset($GLOBALS['exiferFileSize']) && $v == 0 && $bytesofdata < $GLOBALS['exiferFileSize']) { $data = fread($seek, $bytesofdata); } else { $result['Errors'] = $result['Errors']++; $data = ''; } } $formated_data = formatOlympusData($type, $tag, $intel, $data); if ($result['VerboseOutput'] == 1) { $result['SubIFD']['MakerNote'][$tag_name] = $formated_data; if ($type == "URATIONAL" || $type == "SRATIONAL" || $type == "USHORT" || $type == "SSHORT" || $type == "ULONG" || $type == "SLONG" || $type == "FLOAT" || $type == "DOUBLE") { $data = bin2hex($data); if ($intel == 1) { $data = intel2Moto($data); } } $result['SubIFD']['MakerNote'][$tag_name . "_Verbose"]['RawData'] = $data; $result['SubIFD']['MakerNote'][$tag_name . "_Verbose"]['Type'] = $type; $result['SubIFD']['MakerNote'][$tag_name . "_Verbose"]['Bytes'] = $bytesofdata; } else { $result['SubIFD']['MakerNote'][$tag_name] = $formated_data; } } }