-
Notifications
You must be signed in to change notification settings - Fork 0
Create placeholder inside EXIF recording time section (“%er…”) that tries to detect missing EXIF time zone from GPS time (UTC) #3
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
if (!empty($exif['GPS']) && !empty($exif['GPS']['GPSDateStamp']) && !empty($exif['GPS']['GPSTimeStamp'])) {
if (\count($exif['GPS']['GPSTimeStamp']) === 3) {
$gpsFixTimeComponents = [];
for ($i = 0; $i < 3; $i++) {
if (\preg_match('/^([0-9]+)(?:\/([0-9.]+))?$/', $exif['GPS']['GPSTimeStamp'][$i], $matches) === 1) {
if ($matches[2] !== '0' && $matches[2] !== '0.0') {
$gpsFixTimeComponents[] = (int) (((int) $matches[1]) / ((float) $matches[2]));
}
else {
return \UNKNOWN_INFORMATION_MARKER;
}
}
}
$gpsFixDateTimeObj = \DateTime::createFromFormat(
\EXIF_DATE_AND_TIME_FORMAT,
$exif['GPS']['GPSDateStamp'] . ' ' . \sprintf('%02d:%02d:%02d', ...$gpsFixTimeComponents)
);
if ($gpsFixDateTimeObj !== false) {
$diff = $gpsFixDateTimeObj->diff($dateTimeObj);
$sign = $diff->invert === 0 ? '+' : '-';
$hours = (int) \round($diff->y * 12 * 30.436875 * 24 + $diff->m * 30.436875 * 24 + $diff->d * 24 + $diff->h);
$minutes = (int) \round($diff->i + $diff->s / 60);
if ($minutes === 60) {
$hours++;
$minutes = 0;
}
return $sign . \sprintf('%02d', $hours) . ':' . \sprintf('%02d', $minutes);
}
else {
return \UNKNOWN_INFORMATION_MARKER;
}
}
else {
return \UNKNOWN_INFORMATION_MARKER;
}
}
else {
return \UNKNOWN_INFORMATION_MARKER;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request