processFile();
$exif_info = $er->getImageInfo();
set_error_handler("on_error");
// odd behaviour patches here
if (!isset($exif_info['fnumber'])) {
if (isset($exif_info['aperture'])) {
$exif_info['fnumber'] = "f/" . round($exif_info['aperture'], 1);
}
}
if (!isset($exif_info['exposureTime'])) {
if (isset($er->ImageInfo[TAG_SHUTTERSPEED])) {
$exif_info['exposureTime'] = round($er->ImageInfo[TAG_SHUTTERSPEED], 3) . " s (1/" . (int)(1 / $er->ImageInfo['TAG_SHUTTERSPEED']) . ")";
}
} else {
$exifsplit = split("\(" , $exif_info['exposureTime']);
if (isset($exifsplit[2])) {
$exif_info['exposureTime'] = $exifsplit[0] . " (" . $exifsplit[2];
} else {
$exif_info['exposureTime'] = $exifsplit[0] . " (" . $exifsplit[1];
}
}
if (isset($exif_info['focalLength'])) {
$exif_info['focalLength'] = round(substr($exif_info['focalLength'], 0, strpos($exif_info['focalLength'], '(')), 1) . " mm";
}
if (function_exists("exif_read_data") && is_exif_image($filename)) {
$gps_array = gps_exif($filename);
if (isset($gps_array["GPSVersion"])) {
echo "
| GPS | ";
create_gps_url($gps_array);
echo " |
";
}
}
// print all to get the offsets
// debug(print_r ($exif_info,true ));
foreach($lang_exif_info as $label => $key) {
if (!isset($exif_info[$key])) {
$data = $lang_exif_not_available;
} else {
if (($exif_info[$key] != "0") && trim($exif_info[$key]) != "") {
$data = $exif_info[$key];
} else {
$data = $lang_exif_not_available;
}
}
print "| $label | " . cut_info_str(trim($data)) . " |
";
}
}
function ConvertFractionToDecimal($fraction)
{
$result = "";
if (isset($fraction))
{
eval ("\$result = 1.0*$fraction;");
}
return $result;
}
function ExifConvertDegMinSecToDD($deg, $min, $sec)
{
$dec_min = ($min*60.0 + $sec)/60.0;
$result = ($deg*60.0 + $dec_min)/60.0;
return $result;
}
function gps_exif($filename)
{
$exif_data = array();
set_error_handler("on_error_no_output"); // is needed because error are most likly but we don't care about fields we don't even know
$rawexif = @exif_read_data($filename, 0, true);
set_error_handler("on_error");
// GPS Stuff
if (isset($rawexif['GPS']['GPSVersion']))
{
$exif_data['GPSVersion'] = $rawexif['GPS']['GPSVersion'];
$deg = ConvertFractionToDecimal($rawexif['GPS']['GPSLatitude'][0]);
$min = ConvertFractionToDecimal($rawexif['GPS']['GPSLatitude'][1]);
$sec = ConvertFractionToDecimal($rawexif['GPS']['GPSLatitude'][2]);
$exif_data['GPSLatitude'] = ExifConvertDegMinSecToDD($deg, $min, $sec);
$exif_data['GPSLatitudeRef'] = $rawexif['GPS']['GPSLatitudeRef'];
$deg = ConvertFractionToDecimal($rawexif['GPS']['GPSLongitude'][0]);
$min = ConvertFractionToDecimal($rawexif['GPS']['GPSLongitude'][1]);
$sec = ConvertFractionToDecimal($rawexif['GPS']['GPSLongitude'][2]);
$exif_data['GPSLongitude'] = ExifConvertDegMinSecToDD($deg, $min, $sec);
$exif_data['GPSLongitudeRef'] = $rawexif['GPS']['GPSLongitudeRef'];
}
return $exif_data;
}
function create_gps_url($exif)
{
global $default_language;
if (isset($exif['GPSVersion']))
{
echo "Google Maps";
}
}
?>