From 89e53c0955922e5b53d3d4697954a25155c1041b Mon Sep 17 00:00:00 2001 From: Daniela Grammlich Date: Fri, 11 Oct 2019 19:44:41 +0200 Subject: [PATCH] exiftool, Check whether `exiftool` is installed in the host system * refs #2 --- main.inc.php | 53 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/main.inc.php b/main.inc.php index ba5e464..a7ecf21 100644 --- a/main.inc.php +++ b/main.inc.php @@ -17,38 +17,33 @@ function eg_format_exif_data($exif, $filepath, $map) { - $output = shell_exec('exiftool -json "'.$filepath.'"'); - $metadata = json_decode($output, true); + if (shell_exec('exiftool -ver')) { + $output = shell_exec('exiftool -json "' . $filepath . '"'); + $metadata = json_decode($output, true); - foreach ($metadata as $key => $section) { - foreach ($section as $name => $val) { - if(substr( $name, 0, 3 ) === "GPS") - { - if($name === "GPSLatitude" or $name === "GPSLongitude") - { - /* convert to x/1 y/1 z/... format */ - $p1 = explode("deg", $val); - $v1 = intval($p1[0]) . "/1"; - $p2 = explode("'", $p1[1]); - $v2 = intval($p2[0]) . "/1"; + foreach ($metadata as $key => $section) { + foreach ($section as $name => $val) { + if (substr($name, 0, 3) === "GPS") { + if ($name === "GPSLatitude" or $name === "GPSLongitude") { + /* convert to x/1 y/1 z/... format */ + $p1 = explode("deg", $val); + $v1 = intval($p1[0]) . "/1"; + $p2 = explode("'", $p1[1]); + $v2 = intval($p2[0]) . "/1"; - $p3 = explode("\"", $p2[1]); - $v3 = intval($p3[0] * 10000) . "/10000"; + $p3 = explode("\"", $p2[1]); + $v3 = intval($p3[0] * 10000) . "/10000"; - $exif[$name] = array($v1, $v2, $v3); - } - else if($name === "GPSLatitudeRef" or $name === "GPSLongitudeRef") - { - $exif[$name] = substr($val, 0, 1); - } - else - { - $exif[$name] = $val; - } + $exif[$name] = array($v1, $v2, $v3); + } else if ($name === "GPSLatitudeRef" or $name === "GPSLongitudeRef") { + $exif[$name] = substr($val, 0, 1); + } else { + $exif[$name] = $val; + } + } + } } - } - } - return $exif; + return $exif; + } } -?>