ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: stiman on February 14, 2022, 11:46:11 AM

Title: Adjust GPS Altitude of DJI drone photos
Post by: stiman on February 14, 2022, 11:46:11 AM
I have 10 sets of photos from a drone mission.  Set 1 to 7 went normally.  After set 7 was complete they had to change the base station battery.  Once the battery was changed and the power was restored, the GPS Altitude shifted 1.9 meters higher than it was originally.  I would like to use the EXIFTool to replace the GPS Altitude and the Absolute Altitude with the current elevation minus 1.9 meters for data sets 8, 9, and 10.  I copied the photos in sets 8, 9, and 10 into there own directory.  I have downloaded the windows standalone executable and I am hoping some one could help me out with the code I need to make this work.

Thanks,

Scott Timan   
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: wywh on February 14, 2022, 12:26:15 PM
'-GPSAltitude+=-1.9' seems to work. (For some reason '-GPSAltitude-=1.9' doesn't work?):

Set the test file (0 = 'Above Sea Level', 1 = 'Below Sea Level', -n must be used with 0/1):

exiftool -m -P -overwrite_original_in_place -GPSLatitude=36.6101 -GPSLatitudeRef=S -GPSLongitude=66.91515 -GPSLongitudeRef=W -GPSAltitude=101.9 -GPSAltitudeRef='Above Sea Level' dji_p3p.jpg
    1 image files updated

Check the test file:

exiftool -a -G1 -s -n -ee '-*GPS*' dji_p3p.jpg
[GPS]           GPSVersionID                    : 2 3 0 0
[GPS]           GPSLatitudeRef                  : S
[GPS]           GPSLatitude                     : 36.6101
[GPS]           GPSLongitudeRef                 : W
[GPS]           GPSLongitude                    : 66.91515
[GPS]           GPSAltitudeRef                  : 0
[GPS]           GPSAltitude                     : 101.9

Adjust Altitude:

exiftool -m -P -overwrite_original_in_place -GPSAltitude+=-1.9 dji_p3p.jpg
    1 image files updated

Check the result:

exiftool -a -G1 -s -n -ee '-*GPS*' dji_p3p.jpg                           
[GPS]           GPSVersionID                    : 2 3 0 0
[GPS]           GPSLatitudeRef                  : S
[GPS]           GPSLatitude                     : 36.6101
[GPS]           GPSLongitudeRef                 : W
[GPS]           GPSLongitude                    : 66.91515
[GPS]           GPSAltitudeRef                  : 0
[GPS]           GPSAltitude                     : 100


...please correct, if necessary.

- Matti
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: StarGeek on February 14, 2022, 12:47:32 PM
Quote from: wywh on February 14, 2022, 12:26:15 PM
(For some reason '-GPSAltitude-=1.9' doesn't work?)

Because -= is used to conditionally delete a tag with the matching value.  So if GPSAltitude was equal to 1.9, then -GPSAltitude-=1.9 would remove the tag.  The only place where -= will subtract is by shifting date/time related tags.

As an addition, because it's a drone image, there might be drone specific tags.  As long as they're the same name, they will also be adjusted but there might be a chance that the tag name might be slightly different.  I haven't looked over all the tags to be sure.  The command in FAQ #3 (https://exiftool.org/faq.html#Q3) should be used to check and make sure everything is changed.
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: wywh on February 14, 2022, 01:01:44 PM
Quote from: StarGeek on February 14, 2022, 12:47:32 PM
Because -= is used to conditionally delete a tag with the matching value.  So if GPSAltitude was equal to 1.9, then -GPSAltitude-=1.9 would remove the tag.  The only place where -= will subtract is by shifting date/time related tags.

As an addition, because it's a drone image, there might be drone specific tags.

Oh, I see. Thanks.

My sample DJI P3P .dng mangled through Lightroom 6.14 as .jpg has the following "DJI" tags:

[IFD0]          Make                            : DJI
[XMP-rdf]       About                           : DJI Meta Data
[XMP-drone-dji] AbsoluteAltitude                : +202.68
[XMP-drone-dji] FlightPitchDegree               : -20.80
[XMP-drone-dji] FlightRollDegree                : -14.40
[XMP-drone-dji] FlightXSpeed                    : +0.30
[XMP-drone-dji] FlightYSpeed                    : -3.80
[XMP-drone-dji] FlightYawDegree                 : -85.10
[XMP-drone-dji] FlightZSpeed                    : +0.00
[XMP-drone-dji] GimbalPitchDegree               : -24.30
[XMP-drone-dji] GimbalRollDegree                : +0.00
[XMP-drone-dji] GimbalYawDegree                 : -90.90
[XMP-drone-dji] RelativeAltitude                : +116.40


So maybe the OP wants to adjust also 'XMP-drone-dji:AbsoluteAltitude' and 'XMP-drone-dji:RelativeAltitude'. For example:

exiftool -a -G1 -s -n -ee '-*Altitude*' dji_p3p.jpg
[GPS]           GPSAltitudeRef                  : 0
[GPS]           GPSAltitude                     : 101.9
[XMP-drone-dji] AbsoluteAltitude                : 201.9
[XMP-drone-dji] RelativeAltitude                : 101.9

exiftool -m -P -overwrite_original_in_place -GPSAltitude+=-1.9 -AbsoluteAltitude+=-1.9 -RelativeAltitude+=-1.9 dji_p3p.jpg
    1 image files updated

exiftool -a -G1 -s -n -ee '-*Altitude*' dji_p3p.jpg                                                                       
[GPS]           GPSAltitudeRef                  : 0
[GPS]           GPSAltitude                     : 100
[XMP-drone-dji] AbsoluteAltitude                : 200
[XMP-drone-dji] RelativeAltitude                : 100


- Matti
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: stiman on February 14, 2022, 01:54:26 PM
This is the Tag data from one of the pictures

ExifTool Version Number         : 12.40
File Name                       : 100_0008_0001.JPG
Directory                       : C:/Users/stiman/Dropbox (Hi-Crush)/Drone Footage/OnCore 3/Initial FULL Site Data/Flight 8 9 10
File Size                       : 8.0 MiB
File Modification Date/Time     : 2022:02:07 19:50:55-06:00
File Access Date/Time           : 2022:02:14 09:48:28-06:00
File Creation Date/Time         : 2022:02:14 09:41:05-06:00
File Permissions                : -rw-rw-rw-
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel, II)
Image Description               : DCIM\SURVEY\100_0008\100_0
Camera Model Name               : FC6310R
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : v01.09.1759
Modify Date                     : 2022:02:07 13:22:40
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/1000
F Number                        : 4.5
Exposure Program                : Shutter speed priority AE
ISO                             : 100
Exif Version                    : 0230
Date/Time Original              : 2022:02:07 13:22:39
Create Date                     : 2022:02:07 13:22:39
Components Configuration        : -, Cr, Cb, Y
Compressed Bits Per Pixel       : 3.242813895
Shutter Speed Value             : 1/996
Aperture Value                  : 4.5
Exposure Compensation           : 0
Max Aperture Value              : 2.8
Subject Distance                : 0 m
Metering Mode                   : Average
Light Source                    : Daylight
Flash                           : No flash function
Focal Length                    : 8.8 mm
Warning                         : [minor] Possibly incorrect maker notes offsets (fix by 1783?)
Make                            : DJI
Speed X                         : -0.60
Speed Y                         : +0.00
Speed Z                         : +0.00
Pitch                           : -16.10
Yaw                             : -179.90
Roll                            : +0.00
Camera Pitch                    : -90.00
Camera Yaw                      : +175.60
Camera Roll                     : +0.00
Flashpix Version                : 0010
Color Space                     : sRGB
Exif Image Width                : 5472
Exif Image Height               : 3648
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Exposure Index                  : undef
File Source                     : Digital Camera
Scene Type                      : Directly photographed
Custom Rendered                 : Normal
Exposure Mode                   : Auto
White Balance                   : Manual
Digital Zoom Ratio              : undef
Focal Length In 35mm Format     : 24 mm
Scene Capture Type              : Standard
Gain Control                    : None
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : Normal
Subject Distance Range          : Unknown
Serial Number                   : 741959d0e45ea73d56fc2bc8608a0835
GPS Version ID                  : 2.3.0.0
GPS Latitude Ref                : North
GPS Longitude Ref               : West
GPS Altitude Ref                : Above Sea Level
XP Comment                      : Type=N, Mode=S, DE=None
XP Keywords                     : v01.09.1759;1.3.0;v1.0.0
Compression                     : JPEG (old-style)
Thumbnail Offset                : 10240
Thumbnail Length                : 11041
About                           : DJI Meta Data
Format                          : image/jpg
Absolute Altitude               : +996.87
Relative Altitude               : +114.99
GPS Longtitude                  : 103 deg 48' 26.26" W
Gimbal Roll Degree              : +0.00
Gimbal Yaw Degree               : +175.60
Gimbal Pitch Degree             : -90.00
Flight Roll Degree              : +0.00
Flight Yaw Degree               : -179.90
Flight Pitch Degree             : -16.10
Flight X Speed                  : -0.60
Flight Y Speed                  : +0.00
Flight Z Speed                  : +0.00
Cam Reverse                     : 0
Gimbal Reverse                  : 0
Self Data                       : Undefined
Calibrated Focal Length         : 3666.666504
Calibrated Optical Center X     : 2736.000000
Calibrated Optical Center Y     : 1824.000000
Rtk Flag                        : 50
Rtk Std Lon                     : 0.01023
Rtk Std Lat                     : 0.01205
Rtk Std Hgt                     : 0.02511
Dewarp Data                     :  2018-11-07;3663.970000000000,3657.120000000000,-9.390000000000,9.310000000000,-0.262820000000,0.112965000000,0.000818511000,-0.000071285000,-0.041547100000
Dewarp Flag                     : 0
Photo Diff                      :
Version                         : 7.0
Has Settings                    : False
Has Crop                        : False
Already Applied                 : False
MPF Version                     : 0010
Number Of Images                : 2
MP Image Flags                  : Dependent child image
MP Image Format                 : JPEG
MP Image Type                   : Large Thumbnail (VGA equivalent)
MP Image Length                 : 255415
MP Image Start                  : 8121190
Dependent Image 1 Entry Number  : 0
Dependent Image 2 Entry Number  : 0
Image UID List                  : (Binary data 66 bytes, use -b option to extract)
Total Frames                    : 1
Image Width                     : 5472
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                        : 4.5
Image Size                      : 5472x3648
Megapixels                      : 20.0
Scale Factor To 35 mm Equivalent: 2.7
Shutter Speed                   : 1/1000
Thumbnail Image                 : (Binary data 11041 bytes, use -b option to extract)
GPS Altitude                    : 996.8 m Above Sea Level
GPS Latitude                    : 31 deg 57' 45.50" N
GPS Longitude                   : 103 deg 48' 26.26" W
Preview Image                   : (Binary data 255415 bytes, use -b option to extract)
Circle Of Confusion             : 0.011 mm
Field Of View                   : 73.7 deg
Focal Length                    : 8.8 mm (35 mm equivalent: 24.0 mm)
GPS Position                    : 31 deg 57' 45.50" N, 103 deg 48' 26.26" W
Hyperfocal Distance             : 1.56 m
Light Value                     : 14.3g


So would it be exiftool -m -P -overwrite_original_in_place -GPS Altitude+=-1.9 C:\Users\stiman\Desktop\Flight 8 9 10\*.jpg if the files are located in the path listed?

Thanks,

Scott
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: StarGeek on February 14, 2022, 02:05:48 PM
Quote from: stiman on February 14, 2022, 01:54:26 PM
So would it be exiftool -m -P -overwrite_original_in_place -GPS Altitude+=-1.9 C:\Users\stiman\Desktop\Flight 8 9 10\*.jpg if the files are located in the path listed?

No, because "GPS Altitude" is a tag description (see FAQ #2 (https://exiftool.org/faq.html#Q2)), not a tag name.  Tag descriptions can vary based upon the language settings of exiftool and there are never spaces in a tag name.  Also, since you didn't include the -a (-duplicates) option (https://exiftool.org/exiftool_pod.html#a---a--duplicates---duplicates), you are not seeing tags with duplicate names.

Use the command in FAQ #3 (https://exiftool.org/faq.html#Q3) as I said. And you can narrow it down to tags with altitude as part of the name by using wildcards.
exiftool -G1 -a -s -*Altitude* /path/to/files/

If your results are similar to wywh's output for altitude, you can probably use this to adjust all of them
exiftool -*Altitude+=-1.9 /path/to/files/
Edit: This adds some new tags which would have incorrect data

If you only want to target specific tags, then declare those separately.  For example, if you don't want to adjust RelativeAltitude, just the other two, you would use
exiftool -GPSAltitude+=-1.9 -AbsoluteAltitude+=-1.9 /path/to/files/
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: stiman on February 14, 2022, 04:06:25 PM
I really appreciate your efforts to help me.  I am not very programing savvy. I am trying to follow along by looking at the FAQs you are pointing out.  I am trying to use the windows executable to look for the tags using your line exiftool -G1 -a -s -*Altitude* so I can drag one file and drop it on the executable to get the file data.  To do this I have to modify the executable file name to be exiftool(-G1 -a -s -*Altitude*).exe  when I try do do this I get a message pointing out that can't use * in the file name.  What would the correct format be?


Thanks
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: stiman on February 14, 2022, 05:52:10 PM
Ok I think the last suggestion worked so the files are changed thanks for your help.

Scott
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: StarGeek on February 14, 2022, 06:08:54 PM
Quote from: stiman on February 14, 2022, 04:06:25 PMTo do this I have to modify the executable file name to be exiftool(-G1 -a -s -*Altitude*).exe  when I try do do this I get a message pointing out that can't use * in the file name.  What would the correct format be?

Because the asterisk is a special character to the Windows file system, you can't do it by drag and drop.  You'll have to open a CMD.  Or you could list all the altitude tags
exiftool(-G1 -a -s -GPSAltitude -RelativeAltitude -AbsoluteAltitude).exe

Or you could create a batch file and drag drop on there.  You'd have to rename exiftool.  Place this in a text file (use Notepad, not a word processor) and give it a name like Exiftool.bat.
exiftool -k -G1 -a -s -*Altitude* %*
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: wywh on February 17, 2022, 11:33:36 AM
Quote from: StarGeek on February 14, 2022, 02:05:48 PM
you can probably use this to adjust all of them
exiftool -*Altitude+=-1.9 /path/to/files/

If you only want to target specific tags, then declare those separately.  For example, if you don't want to adjust RelativeAltitude, just the other two, you would use
exiftool -GPSAltitude+=-1.9 -AbsoluteAltitude+=-1.9 /path/to/files/

Not a big deal but for some reason using a wildcard like '-*Altitude+=-1.9' inserts several extra XMP-iptcExt tags unless a) -wm w (Write existing tags) is added to the command or b) specific tags are declared.

exiftool -a -G1 -s -n -ee '-*Altitude*' dji_p3p.jpg                     
[GPS]           GPSAltitudeRef                  : 0
[GPS]           GPSAltitude                     : 168.679
[XMP-drone-dji] AbsoluteAltitude                : +168.68
[XMP-drone-dji] RelativeAltitude                : +82.40

exiftool -m -P -overwrite_original_in_place '-*Altitude+=-1.9' dji_p3p.jpg
    1 image files updated
exiftool -m -P -overwrite_original_in_place '-*Altitude+=-10' dji_p3p.jpg
    1 image files updated
exiftool -m -P -overwrite_original_in_place '-*Altitude+=-20' dji_p3p.jpg
    1 image files updated

exiftool -a -G1 -s -n -ee '-*Altitude*' dji_p3p.jpg                       
[GPS]           GPSAltitudeRef                  : 0
[GPS]           GPSAltitude                     : 136.779
[XMP-iptcExt]   LocationCreatedGPSAltitude      : -1.9, -10, -20
[XMP-iptcExt]   LocationShownGPSAltitude        : -1.9, -10, -20
[XMP-iptcExt]   RatingRegionGPSAltitude         : -1.9, -10, -20
[XMP-drone-dji] AbsoluteAltitude                : 136.78
[XMP-drone-dji] RelativeAltitude                : 50.5


- Matti
Title: Re: Adjust GPS Altitude of DJI drone photos
Post by: StarGeek on February 17, 2022, 11:40:27 AM
Quote from: wywh on February 17, 2022, 11:33:36 AM
Not a big deal but for some reason using a wildcard like '-*Altitude+=-1.9' inserts several extra XMP-iptcExt tags unless a) -wm w (Write existing tags) is added to the command or b) specific tags are declared.

Ah, somehow I missed that.  Good catch.