-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.inc.php
More file actions
59 lines (52 loc) · 1.47 KB
/
main.inc.php
File metadata and controls
59 lines (52 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/*
Plugin Name: Exiftool GPS
Version: 0.8
Description: Uses command line exiftool to read exif GPS data. (Plugin based on Exiftool Keywords.)
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=850
Author: ramack, plg
Author URI: http://www.raphael-mack.de
*/
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
add_event_handler('format_exif_data', 'eg_format_exif_data', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
function eg_format_exif_data($exif, $filepath, $map)
{
$json_string = shell_exec('exiftool -json "'.$filepath.'"');
/* Correctif suggéré Mistral 28/11/2025 */
if ($json_string === null)
{
$json_string = '{}'; // ou une valeur par défaut appropriée
}
$metadata = json_decode($json_string, 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";
$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;
}
}
}
}
return $exif;
}
?>