dfandrich / gpscorrelate

C program to match GPS tracks to photographs, and store the matches in the EXIF data in the photographs.
https://dfandrich.github.io/gpscorrelate/
GNU General Public License v2.0
29 stars 8 forks source link

man page says timezone defaults to computer timezone and ignores picture timezone tag? #24

Open marcmerlin opened 10 months ago

marcmerlin commented 10 months ago

All new cameras tag the timezone the picture was taken in Date/Time Original : 2023:11:06 16:15:35 Offset Time : +07:00 Offset Time Original : +07:00 Offset Time Digitized : +07:00

merlin [mc]$ gpscorrelate -g z20231020_Thailand_Vietnam.gpx -t -v *.jpg gives me Date/Time Original : 2023:11:06 16:15:35.181+07:00 GPS Date/Time : 2023:11:07 00:15:35Z

and the GPS tag is just not the correct one. merlin [mc]$ gpscorrelate -R -z+07:00 -g z20231020_Thailand_Vietnam.gpx -t -v *.jpg fixes it, but that means I have to read the GPS offset in the picture and give it to gpscorrelate, instead of it getting it itself. Also, me doing it manually won't work well if a directory has a mix of pictures from different timezones,

Is that working as expected? If so, can the code be improved to use the timezone inside the exif tag? Thanks

dfandrich commented 10 months ago

It's working as designedl; any time zone tag within the image is currently ignored. If a time zone tag is present, it should really be used instead as it is direct evidence instead of inference.

The only test images I have in my collection with time zone information are a few from Nikon DSLRs and they are using a nonstandard MakerNote tag for this. Can you point to upload some test images with time zones?

marcmerlin commented 10 months ago

Sure, thing, I will give you 3 different cameras that do this (last one is cell phone so the picture should already be geotagged) Panasonic TZ200 look for Offset Time : +07:00 Offset Time Original : +07:00 Offset Time Digitized : +07:00 109_20231106_Saigon_Panasonic

merlin [mc]$ exiftool 109_20231106_Saigon_Panasonic.jpg ExifTool Version Number : 12.57 File Name : 109_20231106_Saigon_Panasonic.jpg Directory : . File Size : 651 kB File Modification Date/Time : 2024:01:23 03:26:55-08:00 File Access Date/Time : 2023:11:08 04:11:18-08:00 File Inode Change Date/Time : 2024:01:23 03:26:55-08:00 File Permissions : -rw-r--r-- File Type : JPEG File Type Extension : jpg MIME Type : image/jpeg Exif Byte Order : Little-endian (Intel, II) Make : Panasonic Camera Model Name : DC-ZS200D Orientation : Horizontal (normal) X Resolution : 180 Y Resolution : 180 Resolution Unit : inches Software : Ver.1.0 Modify Date : 2023:11:06 16:15:35 Y Cb Cr Positioning : Co-sited Exposure Time : 1/80 F Number : 6.3 Exposure Program : Program AE ISO : 160 Sensitivity Type : Standard Output Sensitivity Standard Output Sensitivity : 160 Exif Version : 0231 Date/Time Original : 2023:11:06 16:15:35 Create Date : 2023:11:06 16:15:35 Offset Time : +07:00 Offset Time Original : +07:00 Offset Time Digitized : +07:00 Components Configuration : Y, Cb, Cr, - Compressed Bits Per Pixel : 4 Exposure Compensation : +0.33 Max Aperture Value : 4.9 Metering Mode : Multi-segment Light Source : Unknown Flash : Off, Did not fire Focal Length : 29.5 mm Image Quality : High Firmware Version : 0.1.0.0 White Balance : Auto Focus Mode : Auto AF Area Mode : 49-area Image Stabilization : On, Optical Macro Mode : Off Shooting Mode : Program Audio : No Data Dump : (Binary data 24584 bytes, use -b option to extract) Flash Bias : 0 Internal Serial Number : (XGL) 2023:01:02 no. 0104 Panasonic Exif Version : 0414 Color Effect : Off Time Since Power On : 00:01:31.83 Burst Mode : Off Sequence Number : 0 Contrast Mode : 2 Noise Reduction : Standard Self Timer : Off (0) Rotation : Horizontal (normal) AF Assist Lamp : Enabled but Not Used Optical Zoom Mode : Standard Conversion Lens : Off Travel Day : n/a Battery Level : Full World Time Location : Destination Advanced Scene Type : 1 Faces Detected : 0 JPEG Quality : High Color Temp Kelvin : 6200 Bracket Settings : No Bracket WB Shift AB : 0 WB Shift GM : 0 Flash Curtain : n/a Long Exposure Noise Reduction : On Panasonic Image Width : 0 Panasonic Image Height : 0 AF Point Position : 0.62 0.5 Num Face Positions : 0 Lens Type : N/A Lens Serial Number : N/A Accessory Type : NO-ACCESSORY Accessory Serial Number : 0000000 Lens Firmware Version : 0.21.21.0 Faces Recognized : 0 Title : Baby Name : Location : Country : State : City : Landmark : Intelligent Resolution : Standard HDR Shot : Off Burst Speed : 0 Intelligent D-Range : Off Clear Retouch : Off City 2 : Photo Style : Vivid WB Shift Intelligent Auto : 0 Accelerometer Z : 282 Accelerometer X : 5 Accelerometer Y : 10 Camera Orientation : Normal Roll Angle : 1 Pitch Angle : -2.1 WB Shift Creative Control : 0 Sweep Panorama Direction : Off Sweep Panorama Field Of View : 0 Timer Recording : Off Internal ND Filter : 0 HDR : Off Shutter Type : Mechanical Filter Effect : Off Clear Retouch Value : undef Touch AE : Off Monochrome Filter Effect : Off Highlight Shadow : 0 0 Time Stamp : 2023:11:06 09:15:35 Video Burst Resolution : Off or 4K Multi Exposure : Off Red Eye Removal : Off Video Burst Mode : Off Diffraction Correction : Off Focus Bracket : 0 Long Exposure NR Used : Yes Post Focus Merging : Post Focus Auto Merging or None Video Preburst : No Lens Type Make : 0 Sensor Type : Multi-aspect Monochrome Grain Effect : Off Time Lapse Shot Number : 0 Maker Note Version : 0154 Scene Mode : Off Highlight Warning : No Dark Focus Environment : No WB Red Level : 2747 WB Green Level : 1024 WB Blue Level : 1830 Text Stamp : Off Baby Age : (not set) Sub Sec Time : 181 Sub Sec Time Original : 181 Sub Sec Time Digitized : 181 Flashpix Version : 0100 Color Space : sRGB Exif Image Width : 5472 Exif Image Height : 3080 Interoperability Index : R98 - DCF basic file (sRGB) Interoperability Version : 0100 Sensing Method : One-chip color area File Source : Digital Camera Scene Type : Directly photographed Custom Rendered : Normal Exposure Mode : Auto Digital Zoom Ratio : 0 Focal Length In 35mm Format : 84 mm Scene Capture Type : Standard Gain Control : Low gain up Contrast : Normal Saturation : Normal Sharpness : Normal GPS Version ID : 2.2.0.0 GPS Latitude Ref : North GPS Longitude Ref : East GPS Altitude Ref : Above Sea Level GPS Time Stamp : 00:15:35 GPS Map Datum : WGS-84 GPS Date Stamp : 2023:11:07 PrintIM Version : 0250 Compression : JPEG (old-style) Thumbnail Offset : 29880 Thumbnail Length : 0 XMP Toolkit : XMP Core 4.4.0-Exiv2 Rating : 0 Instance ID : uuid:d874e788-25f8-4d1d-947a-6e77822b5d6a Image Width : 5472 Image Height : 3080 Encoding Process : Baseline DCT, Huffman coding Bits Per Sample : 8 Color Components : 3 Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1) Aperture : 6.3 Blue Balance : 1.787109 Image Size : 5472x3080 Megapixels : 16.9 Red Balance : 2.682617 Scale Factor To 35 mm Equivalent: 2.8 Shutter Speed : 1/80 Create Date : 2023:11:06 16:15:35.181+07:00 Date/Time Original : 2023:11:06 16:15:35.181+07:00 Modify Date : 2023:11:06 16:15:35.181+07:00 GPS Altitude : 24.9 m Above Sea Level GPS Date/Time : 2023:11:07 00:15:35Z GPS Latitude : 10 deg 46' 16.21" N GPS Longitude : 106 deg 41' 53.31" E Advanced Scene Mode : Off Circle Of Confusion : 0.011 mm Field Of View : 24.2 deg Focal Length : 29.5 mm (35 mm equivalent: 84.0 mm) GPS Position : 10 deg 46' 16.21" N, 106 deg 41' 53.31" E Hyperfocal Distance : 13.09 m Light Value : 11.0

marcmerlin commented 10 months ago

Pixel 8 Pro has the same Offset Time : +07:00 Offset Time Original : +07:00 Offset Time Digitized : +07:00

merlin [mc]$ exiftool 110_20231106_Saigon_Google.jpg ExifTool Version Number : 12.57 File Name : 110_20231106_Saigon_Google.jpg Directory : . File Size : 1691 kB File Modification Date/Time : 2024:01:23 02:47:20-08:00 File Access Date/Time : 2024:01:23 02:47:20-08:00 File Inode Change Date/Time : 2024:01:23 02:47:20-08:00 File Permissions : -rw-r--r-- File Type : JPEG File Type Extension : jpg MIME Type : image/jpeg Exif Byte Order : Little-endian (Intel, II) Make : Google Camera Model Name : Pixel 8 Pro Orientation : Horizontal (normal) X Resolution : 72 Y Resolution : 72 Resolution Unit : inches Software : HDR+ 1.0.575362751zd Modify Date : 2023:11:06 17:18:32 Y Cb Cr Positioning : Centered Exposure Time : 1/100 F Number : 1.9 Exposure Program : Program AE ISO : 363 Exif Version : 0232 Date/Time Original : 2023:11:06 17:18:32 Create Date : 2023:11:06 17:18:32 Offset Time : +07:00 Offset Time Original : +07:00 Offset Time Digitized : +07:00 Components Configuration : Y, Cb, Cr, - Shutter Speed Value : 1/100 Aperture Value : 2.0 Brightness Value : 1.71 Exposure Compensation : 0 Max Aperture Value : 2.0 Subject Distance : 4.871 m Metering Mode : Center-weighted average Flash : Off, Did not fire Focal Length : 2.2 mm Sub Sec Time : 115 Sub Sec Time Original : 115 Sub Sec Time Digitized : 115 Flashpix Version : 0100 Color Space : sRGB Exif Image Width : 4080 Exif Image Height : 3072 Interoperability Index : R98 - DCF basic file (sRGB) Interoperability Version : 0100 Sensing Method : One-chip color area Scene Type : Directly photographed Custom Rendered : Custom Exposure Mode : Auto White Balance : Auto Digital Zoom Ratio : 0 Focal Length In 35mm Format : 12 mm Scene Capture Type : Standard Contrast : Normal Saturation : Normal Sharpness : Normal Subject Distance Range : Distant Lens Make : Google Lens Model : Pixel 8 Pro back camera 2.23mm f/1.95 Composite Image : Composite Image Captured While Shooting GPS Version ID : 2.2.0.0 GPS Latitude Ref : North GPS Longitude Ref : East GPS Altitude Ref : Above Sea Level GPS Time Stamp : 10:18:28 GPS Img Direction Ref : Magnetic North GPS Img Direction : 31 GPS Date Stamp : 2023:11:06 Compression : JPEG (old-style) Thumbnail Offset : 1315 Thumbnail Length : 0 XMP Toolkit : Adobe XMP Core 5.1.0-jc003 Version : 1.0 Has Extended XMP : 93BF302D067E68D5D761860B7E0F4FCA Directory Item Semantic : Primary Directory Item Mime : image/jpeg Directory Item Length : 92436 Profile CMM Type : Profile Version : 4.0.0 Profile Class : Display Device Profile Color Space Data : RGB Profile Connection Space : XYZ Profile Date Time : 2023:03:09 10:57:00 Profile File Signature : acsp Primary Platform : Unknown () CMM Flags : Not Embedded, Independent Device Manufacturer : Google Device Model : Device Attributes : Reflective, Glossy, Positive, Color Rendering Intent : Perceptual Connection Space Illuminant : 0.9642 1 0.82491 Profile Creator : Google Profile ID : 61473528d5aaa311e143dfc93efaa268 Profile Description : sRGB IEC61966-2.1 Profile Copyright : Copyright (c) 2023 Google Inc. Media White Point : 0.9642 1 0.82491 Media Black Point : 0 0 0 Red Matrix Column : 0.43604 0.22249 0.01392 Green Matrix Column : 0.38512 0.7169 0.09706 Blue Matrix Column : 0.14305 0.06061 0.71391 Red Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract) Chromatic Adaptation : 1.04788 0.02292 -0.05019 0.02959 0.99048 -0.01704 -0.00922 0.01508 0.75168 Blue Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract) Green Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract) Image Width : 4080 Image Height : 3072 Encoding Process : Baseline DCT, Huffman coding Bits Per Sample : 8 Color Components : 3 Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2) Aperture : 1.9 Image Size : 4080x3072 Megapixels : 12.5 Scale Factor To 35 mm Equivalent: 5.4 Shutter Speed : 1/100 Create Date : 2023:11:06 17:18:32.115+07:00 Date/Time Original : 2023:11:06 17:18:32.115+07:00 Modify Date : 2023:11:06 17:18:32.115+07:00 GPS Altitude : 16.2 m Above Sea Level GPS Date/Time : 2023:11:06 10:18:28Z GPS Latitude : 10 deg 48' 58.93" N GPS Longitude : 106 deg 39' 47.39" E Circle Of Confusion : 0.006 mm Depth Of Field : inf (0.42 m - inf) Field Of View : 112.6 deg Focal Length : 2.2 mm (35 mm equivalent: 12.0 mm) GPS Position : 10 deg 48' 58.93" N, 106 deg 39' 47.39" E Hyperfocal Distance : 0.46 m Light Value : 6.7 Lens ID : Pixel 8 Pro back camera 2.23mm f/1.95

marcmerlin commented 10 months ago

Sony RX100M7 same thing too Offset Time : +07:00 Offset Time Original : +07:00 Offset Time Digitized : +07:00

merlin [mc]$ exiftool 115_20231106_Saigon_SONY.jpg ExifTool Version Number : 12.57 File Name : 115_20231106_Saigon_SONY.jpg Directory : . File Size : 1917 kB File Modification Date/Time : 2023:11:08 04:10:43-08:00 File Access Date/Time : 2023:11:08 04:10:43-08:00 File Inode Change Date/Time : 2024:01:23 02:47:14-08:00 File Permissions : -rw-r--r-- File Type : JPEG File Type Extension : jpg MIME Type : image/jpeg Exif Byte Order : Little-endian (Intel, II) Image Description : Make : SONY Camera Model Name : DSC-RX100M7 Orientation : Horizontal (normal) X Resolution : 350 Y Resolution : 350 Resolution Unit : inches Software : DSC-RX100M7 v1.00 Modify Date : 2023:11:06 19:13:00 Y Cb Cr Positioning : Co-sited Exposure Time : 1/40 F Number : 2.8 ISO : 100 Sensitivity Type : Recommended Exposure Index Recommended Exposure Index : 100 Exif Version : 0231 Date/Time Original : 2023:11:06 19:13:00 Create Date : 2023:11:06 19:13:00 Offset Time : +07:00 Offset Time Original : +07:00 Offset Time Digitized : +07:00 Components Configuration : Y, Cb, Cr, - Compressed Bits Per Pixel : 2 Brightness Value : 4.025 Exposure Compensation : -0.7 Max Aperture Value : 2.8 Metering Mode : Multi-segment Light Source : Unknown Flash : Off, Did not fire Focal Length : 9.0 mm Brightness : 0 Long Exposure Noise Reduction : On (unused) High ISO Noise Reduction : Normal HDR : Off; Uncorrected image WB Shift AB GM : 0 0 WB Shift AB GM Precise : 0.00 0.00 Face Info Offset : 94 Sony Date Time : 2023:11:06 19:13:00 Sony Image Width : 4864 Faces Detected : 0 Face Info Length : 37 Meta Version : DC7303320222000 Creative Style : Standard Color Temperature : Auto Color Compensation Filter : 0 Scene Mode : Standard Zone Matching : ISO Setting Used Dynamic Range Optimizer : Auto Image Stabilization : On Color Mode : Standard Full Image Size : 4864x3648 Preview Image Size : 1440x1080 File Format : ARW 2.3.5 Flash Exposure Compensation : 0 White Balance Fine Tune : 0 White Balance : Auto Sony Model ID : DSC-RX100M7 Multi Frame Noise Reduction : Off Picture Effect : Off Soft Skin Effect : Off Vignetting Correction : n/a Lateral Chromatic Aberration : n/a Distortion Correction Setting : n/a Lens Spec : 24-200mm F2.8-4.5 Auto Portrait Framed : No Flash Action : Did not fire Electronic Front Curtain Shutter: Off Focus Mode : AF-A AF Area Mode Setting : Wide Flexible Spot Position : 0 0 AF Tracking : Off Focal Plane AF Points Used : 2 Focal Plane AF Point Area : 640 480 Focal Plane AF Point Location 1 : 156 242 Focal Plane AF Point Location 2 : 156 216 Multi Frame NR Effect : Normal Focus Location : 4864 3648 1185 1839 Variable Low Pass Filter : n/a Priority Set In AWB : Standard Metering Mode 2 : Multi-segment Exposure Standard Adjustment : 0 RAW File Type : Compressed RAW Quality : Fine Flash Level : Normal Release Mode : Normal Sequence Number : Single Anti-Blur : On (Continuous) High ISO Noise Reduction 2 : Normal Release Mode 2 : Normal Sequence Image Number : 1 Sequence File Number : 1 Sequence Length : 1 file Camera Orientation : Horizontal (normal) Quality 2 : JPEG Sony Image Height : 3648 Model Release Year : 2018 ISO Setting : Auto ISO Auto Min : 100 ISO Auto Max : 6400 Ambient Temperature : 30 C AF Area Mode : Multi Camera Temperature : 32 C Exposure Program : Program AE Intelligent Auto : Off Sony ISO : 100 Base ISO : 100 Stops Above Base ISO : 0 Sony Exposure Time 2 : 1/38 Sony Max Aperture Value : 3.0 Sony Image Width Max : 5496 Sony Image Height Max : 3672 Picture Effect 2 : Off Distortion Correction : Applied Lens Zoom Position : 0% Release Mode 3 : Normal Self Timer : Off Flash Mode : Fill-flash HDR Setting : Off Picture Profile : Gamma Still - Standard/Neutral (PP2) WB RGB Levels : 487 256 469 Min Focal Length : 9.0 mm Max Focal Length : 72.0 mm User Comment : Flashpix Version : 0100 Color Space : sRGB Exif Image Width : 4864 Exif Image Height : 3648 Interoperability Index : R98 - DCF basic file (sRGB) Interoperability Version : 0100 File Source : Digital Camera Scene Type : Directly photographed Custom Rendered : Normal Exposure Mode : Auto Digital Zoom Ratio : 1 Focal Length In 35mm Format : 24 mm Scene Capture Type : Standard Contrast : Normal Saturation : Normal Sharpness : Normal Lens Info : 9-72mm f/2.8-4.5 GPS Version ID : 2.3.0.0 GPS Latitude Ref : North GPS Longitude Ref : East GPS Time Stamp : 12:13:01 GPS Status : Measurement Active GPS Measure Mode : 2-Dimensional Measurement GPS Map Datum : WGS-84 GPS Date Stamp : 2023:11:06 GPS Differential : No Correction PrintIM Version : 0300 Compression : JPEG (old-style) Thumbnail Offset : 35074 Thumbnail Length : 0 Rating : 0 Image Width : 4864 Image Height : 3648 Encoding Process : Baseline DCT, Huffman coding Bits Per Sample : 8 Color Components : 3 Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1) Aperture : 2.8 Blue Balance : 1.832031 Image Size : 4864x3648 Megapixels : 17.7 Red Balance : 1.902344 Scale Factor To 35 mm Equivalent: 2.7 Shutter Speed : 1/40 Create Date : 2023:11:06 19:13:00+07:00 Date/Time Original : 2023:11:06 19:13:00+07:00 Modify Date : 2023:11:06 19:13:00+07:00 GPS Date/Time : 2023:11:06 12:13:01Z GPS Latitude : 10 deg 46' 2.70" N GPS Longitude : 106 deg 41' 38.27" E Circle Of Confusion : 0.011 mm Field Of View : 73.7 deg Focal Length : 9.0 mm (35 mm equivalent: 24.0 mm) GPS Position : 10 deg 46' 2.70" N, 106 deg 41' 38.27" E Hyperfocal Distance : 2.57 m Light Value : 8.3

marcmerlin commented 10 months ago

For now, I wrote this. It's not perfect since it will not support timezone changes within a direction, but otherwise it should work:

TZ=$(ls -1 *.jpg | head -1 | xargs exiftool | grep -i 'Offset Time *:' | sed "s/.*: //")

[[ $(echo $TZ | wc -c) != 7 ]] && echo "Failed TZ; $TZ" && exit
echo "Timezone offset from first picture: $TZ"
sleep 2

gpscorrelate -R -z$TZ -g .track.gpx -t -v *.jpg 
dfandrich commented 10 months ago

The Offset Time tags were added to EXIF relatively recently (ver. 3.21 in 2016). I know the last time I looked for a standardized way of representing this, it didn't exist. It makes to add support, probably by default.

marcmerlin commented 8 months ago

any chance this can be added? my workaround is ok, except when I have mixed timezones in a directory, and then it falls over :)

dfandrich commented 8 months ago

It most definitely can be added, but I'm desperately trying to get the long-overdue release out (that's stalled on a French translation) so unless someone sends a PR it will happen after that.