function get_Nikon_Text_Value($Exif_Tag, $Tag_Definitions_Name) { // Check that this tag uses the Nikon tags, otherwise it can't be interpreted here // And check which variety of tags if ($Tag_Definitions_Name == "Nikon Type 1") { // No special tags for Nikon type 1 so far return FALSE; } else { if ($Tag_Definitions_Name == "Nikon Type 3") { // Nikon Type 3 special tag // Process tag according to it's tag number if ($Exif_Tag['Tag Number'] == 1) { return "\"" . HTML_UTF8_Escape($Exif_Tag['Data']) . "\" (" . bin2hex($Exif_Tag['Data']) . " hex)"; } else { if ($Exif_Tag['Tag Number'] == 2 || $Exif_Tag['Tag Number'] == 19) { // ISO speed settings - should be the second of two values if (count($Exif_Tag['Data']) == 2) { // There are two values - display the second return $Exif_Tag['Data'][1] . " " . $Exif_Tag['Units']; } else { // There is not two values - display generic version of values return get_IFD_value_as_text($Exif_Tag['Data']) . " " . $Exif_Tag['Units']; } } else { if ($Exif_Tag['Tag Number'] == 137) { // Add shooting mode to output from first two bits switch ($Exif_Tag['Data'][0] & 0x3) { case 0x0: $outputstr = "Shooting Mode: Single Frame\n"; break; case 0x1: $outputstr = "Shooting Mode: Continuous\n"; break; case 0x2: $outputstr = "Shooting Mode: Self Timer\n"; break; case 0x3: $outputstr = "Shooting Mode: Remote??\n"; break; default: $outputstr = "Shooting Mode: Unknown\n"; break; } // Add flash bracketing to output from fifth bit if (($Exif_Tag['Data'][0] & 0x10) == 0x10) { $outputstr .= "AE/Flash Bracketing On\n"; } else { $outputstr .= "AE/Flash Bracketing Off\n"; } // Add white balance bracketing to output from seventh bit if (($Exif_Tag['Data'][0] & 0x40) == 0x40) { $outputstr .= "White Balance Bracketing On\n"; } else { $outputstr .= "White Balance Bracketing Off\n"; } // Return the output return $outputstr; } else { if ($Exif_Tag['Tag Number'] == 136) { // Create a string to receive the output $outputstr = ""; // If all zeros, this could be manual focus if ($Exif_Tag['Data'] == "") { $outputstr .= "Manual Focus, or\n"; } // Add AF mode according to the first byte switch (ord($Exif_Tag['Data'][0])) { case 0x0: $outputstr .= "Auto Focus Mode: Single Area\n"; break; case 0x1: $outputstr .= "Auto Focus Mode: Dynamic Area\n"; break; case 0x2: $outputstr .= "Auto Focus Mode: Closest Subject\n"; break; default: $outputstr .= "Auto Focus Mode: Unknown AF Mode\n"; break; } // Add AF area according to second byte switch (ord($Exif_Tag['Data'][1])) { case 0x0: $outputstr .= "Auto Focus Area Selected: Centre\n"; break; case 0x1: $outputstr .= "Auto Focus Area Selected: Top\n"; break; case 0x2: $outputstr .= "Auto Focus Area Selected: Bottom\n"; break; case 0x3: $outputstr .= "Auto Focus Area Selected: Left\n"; break; case 0x4: $outputstr .= "Auto Focus Area Selected: Right\n"; break; } // Add properly focused areas to output according to byte 3 bits $outputstr .= "Properly Focused Area(s): "; if (ord($Exif_Tag['Data'][3]) == 0x0) { $outputstr .= "None"; } if ((ord($Exif_Tag['Data'][3]) & 0x1) == 0x1) { $outputstr .= "Centre "; } if ((ord($Exif_Tag['Data'][3]) & 0x2) == 0x2) { $outputstr .= "Top "; } if ((ord($Exif_Tag['Data'][3]) & 0x4) == 0x4) { $outputstr .= "Bottom "; } if ((ord($Exif_Tag['Data'][3]) & 0x8) == 0x8) { $outputstr .= "Left "; } if ((ord($Exif_Tag['Data'][3]) & 0x10) == 0x10) { $outputstr .= "Right "; } $outputstr .= "\n"; // return the string return $outputstr; } else { // Unknown special tag return FALSE; } } } } } } return FALSE; }
function get_Tag_Text_Value($Tag, $Tag_Definitions_Name) { // Check what format the entry is specified as if ($Tag['Type'] == "String") { // Format is Text String // If "Unknown" (type 7) data type, if ($Tag['Data Type'] == 7) { // Return data as is. return $Tag['Data']; } else { // Otherwise return the default string value of the datatype return get_IFD_value_as_text($Tag); } } else { if ($Tag['Type'] == "Character Coded String") { // Format is Character Coded String (First 8 characters indicate coding scheme) // Convert Data to a string if ($Tag['Data Type'] == 7) { // If it is type "Unknown" (type 7) use data as is $data = $Tag['Data']; } else { // Otherwise use the default string value of the datatype $data = get_IFD_value_as_text($Tag); } // Some implementations allow completely data with no Coding Scheme Name, // so we need to handle this to avoid errors if (trim($data) == "") { return ""; } // Extract the Coding Scheme Name from the first 8 characters $char_code = substr($data, 0, 8); // Extract the Data part from after the first 8 characters $characters = substr($data, 8); // Check coding scheme and interpret as neccessary if ($char_code === "ASCII") { // ASCII coding - return data as is. return $characters; } elseif ($char_code === "UNICODE" || $char_code === "Unicode") { // Unicode coding - interpret and return result. return xml_UTF16_clean($characters, TRUE); } else { // Unknown coding - return string indicating this return "Unsupported character coding : \"{$char_code}\"\n\"" . trim($characters) . "\""; } } else { if ($Tag['Type'] == "Numeric") { // Format is numeric - return default text value with any required units text appended if (array_key_exists('Units', $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag["Tag Number"]])) { $units = $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag["Tag Number"]]['Units']; } else { $units = ""; } return get_IFD_value_as_text($Tag) . " " . $units; } else { if ($Tag['Type'] == "Lookup") { // Format is a Lookup Table // Get a numeric value to use in lookup if (is_array($Tag['Data'])) { // If data is an array, use first element $first_val = $Tag['Data'][0]; } else { if (is_string($Tag['Data'])) { // If data is a string, use the first character $first_val = ord($Tag['Data'][0]); } else { // Otherwise use the data as is $first_val = $Tag['Data']; } } // Check if the data value exists in the lookup table for this IFD entry if (array_key_exists($first_val, $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag["Tag Number"]])) { // Data value exists in lookup table - return the matching string return $GLOBALS["IFD_Tag_Definitions"][$Tag_Definitions_Name][$Tag["Tag Number"]][$first_val]; } else { // Data value doesnt exist in lookup table - return explanation string return "Unknown Reserved value {$first_val} "; } } else { if ($Tag['Type'] == "Special") { // Format is special - interpret to text with special handlers return get_Special_Tag_Text_Value($Tag, $Tag_Definitions_Name); } else { if ($Tag['Type'] == "PIM") { // Format is Print Image Matching info - interpret with custom handler return get_PIM_Text_Value($Tag, $Tag_Definitions_Name); } else { if ($Tag['Type'] == "SubIFD") { // Format is a Sub-IFD - this has no text value return ""; } else { // Unknown Format - Couldn't interpret using the IFD_Tag_Definitions global array information return FALSE; } } } } } } } }