Error Opening File When Copying Geotags from H20T Jpg to Tiff, Help Please

Started by Dragonmaster150, January 28, 2023, 02:20:08 AM

Previous topic - Next topic

Dragonmaster150

Hello, I'm currently working on a project with some thermal images from the DJI H20T drone sensor where I am converting them to Tiff format so they can be orthorectified (Fancy word for properly formatted) in Correlator 3D for use in software like ArcGIS and QGIS.

I've already found a way to convert the images from the .jpg format to the .tiff format. However, when examining these Tiff Images with ExifTool using the -ee command shows that they do not appear to keep the gps metadata. This includes things like flight speed, altitude, Gimbal yaw pitch, GPS co-ordinate and so on which are still present in the raw jpgs. After doing some looking around, I came across this command for ExifTool: exiftool -ext tiff -TagsFromFile %d%f.jpg -GPS:all -AllDates /path/to/files/ which, from what I understand, should allow me to copy all of the GPS data from the jpgs to the tiffs.

However, attempting to use that in the command line with my batch of test images resulted in this error:
C:\Users\me>"C:\Program Files\ExifTool\exiftool.exe" -ext tiff -TagsFromFile %d%f.jpg -GPS:all -AllDates "C:\Users\me\Desktop\Image_Conversion_Test\Raw_Test_Images"
Warning: Error opening file - C:/Users/me/Desktop/Image_Conversion_Test/Raw_Test_Images/DJI_20221027174013_0906_T_TEMP.jpg
Warning: Error opening file - C:/Users/me/Desktop/Image_Conversion_Test/Raw_Test_Images/DJI_20221027174015_0907_T_TEMP.jpg
Warning: Error opening file - C:/Users/me/Desktop/Image_Conversion_Test/Raw_Test_Images/DJI_20221027174017_0908_T_TEMP.jpg
Warning: Error opening file - C:/Users/me/Desktop/Image_Conversion_Test/Raw_Test_Images/DJI_20221027174105_0928_T_TEMP.jpg
Warning: Error opening file - C:/Users/me/Desktop/Image_Conversion_Test/Raw_Test_Images/DJI_20221027174108_0929_T_TEMP.jpg
Warning: Error opening file - C:/Users/me/Desktop/Image_Conversion_Test/Raw_Test_Images/DJI_20221027174110_0930_T_TEMP.jpg
    1 directories scanned
    0 image files updated
    6 image files unchanged

I am aware that I could use the metadata written as a .txt file to perform the photogrammetry in Correlator 3D, I think. However, I was hoping that I would just be able to import the images without needing to deal with extra files.

As I'm still rather new to using ExifTool, and programming in general, so any insight would be very appreciated.

-Sincerely, Dragon

StarGeek

Exiftool can't find your jpegs. Your command is such that the jpegs must be in the same directory as the tiffs and with the same exact base name.  Are you sure they are in the directory listed and with the names listed?

If the names are right, can you share a jpeg and the matching tiff?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Dragonmaster150

Quote from: StarGeek on January 28, 2023, 03:56:27 AMExiftool can't find your jpegs. Your command is such that the jpegs must be in the same directory as the tiffs and with the same exact base name.  Are you sure they are in the directory listed and with the names listed?

If the names are right, can you share a jpeg and the matching tiff?

Thanks for replying, I've uploaded a matching pair to Google Drive, one Tiff one JPG. You should be able to get them from here: https://drive.google.com/drive/folders/1sxM7JjJEQNirUepYkJECEhP0D53FR9ng?usp=sharing


I think you're right, As I was grabbing the images I just noticed that there's a discrepancy in the naming. It looks like the script I'm using is adding "_TEMP" to the end of the image name when it does the file conversion.

Do you have any advice or suggestions for how I could alter the command if I were to move the Tiffs to a different directory without changing the name? I think I read on another post that it has to do with the %d and the %f, but I'm having a tough time trying to wrap my head around it.

Thank you once again, I greatly appreciate your help

StarGeek

Quote from: Dragonmaster150 on January 28, 2023, 04:53:30 AMI think you're right, As I was grabbing the images I just noticed that there's a discrepancy in the naming. It looks like the script I'm using is adding "_TEMP" to the end of the image name when it does the file conversion.

Yes, that is the problem. The files aren't needed unless there's another problem. When one of the tiff files is found, the %d stands for the directory of the tiff file and %f stands for the name of the file without the extension.  So the "_Temp" breaks the filename part.

Quoteif I were to move the Tiffs to a different directory without changing the name?

If you move the tiffs to a different directory, then that means you'll have to change the %d variable that points to the jpegs.  You would just replace that with the path to the other directory.  Or if there's a pattern, then it might be editable with the %d.  You'd have to be more detailed in the change.

But if you keep it as it is, then all that is needed is to drop the "_Temp" from the filename, which would consist of removing the last 5 characters.  If you look at the examples under the Advanced Features section of the -w (-TextOut) option, the second example shows how to remove four characters from the end of the filename.  That just needs to be changed to five.

exiftool.exe -ext tiff -TagsFromFile %d%-.5f.jpg -GPS:all -AllDates /path/to/files/

Example output using your files.  I included -XMP:AllDates in this example to also copy the XMP timestamps, though it may not be necessary for your use.
C:\>exiftool -G1 -a -s -e -gps* -alldates Y:\!temp\dd\aa\
======== Y:/!temp/dd/aa/DJI_20221027174015_0907_T.JPG
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 49 deg 42' 43.91"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 116 deg 45' 55.70"
[GPS]           GPSAltitudeRef                  : Above Sea Level
[GPS]           GPSAltitude                     : 865.003 m
[GPS]           GPSStatus                       : Measurement Active
[GPS]           GPSMapDatum                     : WGS-84
[XMP-drone-dji] GpsStatus                       : RTK
[XMP-drone-dji] GPSLatitude                     : 49 deg 42' 43.91" N
[XMP-drone-dji] GPSLongitude                    : 116 deg 45' 55.70" W
[ExifIFD]       DateTimeOriginal                : 2022:10:27 17:40:15
[ExifIFD]       CreateDate                      : 2022:10:27 17:40:15
[XMP-xmp]       CreateDate                      : 2022:10:27 17:40:15-07:00
[IFD0]          ModifyDate                      : 2022:10:27 17:40:15
[XMP-xmp]       ModifyDate                      : 2022:10:27 17:40:15-07:00
======== Y:/!temp/dd/aa/DJI_20221027174015_0907_T_TEMP.tiff
======== Y:/!temp/dd/aa/drive-download-20230128T162852Z-001.zip
    1 directories scanned
    3 image files read

C:\>exiftool -P -overwrite_original -ext tiff -TagsFromFile %d%-.5f.jpg -GPS:all -AllDates -XMP:AllDates Y:\!temp\dd\aa
Warning: [minor] Bad MakerNotes directory - Y:/!temp/dd/aa/DJI_20221027174015_0907_T.jpg
    1 directories scanned
    1 image files updated

C:\>exiftool -G1 -a -s -e -gps* -alldates Y:\!temp\dd\aa\
======== Y:/!temp/dd/aa/DJI_20221027174015_0907_T.JPG
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 49 deg 42' 43.91"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 116 deg 45' 55.70"
[GPS]           GPSAltitudeRef                  : Above Sea Level
[GPS]           GPSAltitude                     : 865.003 m
[GPS]           GPSStatus                       : Measurement Active
[GPS]           GPSMapDatum                     : WGS-84
[XMP-drone-dji] GpsStatus                       : RTK
[XMP-drone-dji] GPSLatitude                     : 49 deg 42' 43.91" N
[XMP-drone-dji] GPSLongitude                    : 116 deg 45' 55.70" W
[ExifIFD]       DateTimeOriginal                : 2022:10:27 17:40:15
[ExifIFD]       CreateDate                      : 2022:10:27 17:40:15
[XMP-xmp]       CreateDate                      : 2022:10:27 17:40:15-07:00
[IFD0]          ModifyDate                      : 2022:10:27 17:40:15
[XMP-xmp]       ModifyDate                      : 2022:10:27 17:40:15-07:00
======== Y:/!temp/dd/aa/DJI_20221027174015_0907_T_TEMP.tiff
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 49 deg 42' 43.91"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 116 deg 45' 55.70"
[GPS]           GPSAltitudeRef                  : Above Sea Level
[GPS]           GPSAltitude                     : 865.003003 m
[GPS]           GPSStatus                       : Measurement Active
[GPS]           GPSMapDatum                     : WGS-84
[ExifIFD]       DateTimeOriginal                : 2022:10:27 17:40:15
[XMP-xmp]       CreateDate                      : 2022:10:27 17:40:15-07:00
[ExifIFD]       CreateDate                      : 2022:10:27 17:40:15
[IFD0]          ModifyDate                      : 2022:10:27 17:40:15
[XMP-xmp]       ModifyDate                      : 2022:10:27 17:40:15-07:00
======== Y:/!temp/dd/aa/drive-download-20230128T162852Z-001.zip
    1 directories scanned
    3 image files read
[
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Dragonmaster150

Ok, so if I'm understanding this right, using the -w command I can remove the added characters. In the example you have: exiftool.exe -ext tiff -TagsFromFile %d%-.5f.jpg -GPS:all -AllDates /path/to/files/ the %-.5f.jpg is performing the same function, which I can see by cross referencing with the location in the ExifTool Docs.

I've gone ahead and tested it and it looks like it works, I've confimed that all the tags were added successfully as well.

C:\Users\me>"C:\Program Files\ExifTool\exiftool.exe" -ext tiff -TagsFromFile %d%-.5f.jpg -GPS:all -AllDates "C:\Users\me\Desktop\Image_Conversion_Test\Test_Images"
Warning: [minor] Bad MakerNotes directory - C:/Users/me/Desktop/Image_Conversion_Test/Test_Images/DJI_20221027174015_0907_T.jpg
    1 directories scanned
    1 image files updated

C:\Users\me>"C:\Program Files\ExifTool\exiftool.exe" -ee "C:\Users\me\Desktop\Image_Conversion_Test\Test_Images\DJI_20221027174015_0907_T_TEMP.tiff"
ExifTool Version Number         : 12.55
File Name                       : DJI_20221027174015_0907_T_TEMP.tiff
Directory                       : C:/Users/marcu/Desktop/Image_Conversion_Test/Test_Images
File Size                       : 656 kB
File Modification Date/Time     : 2023:01:28 11:54:16-08:00
File Access Date/Time           : 2023:01:28 11:55:37-08:00
File Creation Date/Time         : 2023:01:28 01:26:51-08:00
File Permissions                : -rw-rw-rw-
File Type                       : TIFF
File Type Extension             : tif
MIME Type                       : image/tiff
Exif Byte Order                 : Little-endian (Intel, II)
Image Width                     : 640
Image Height                    : 512
Bits Per Sample                 : 16
Compression                     : Uncompressed
Photometric Interpretation      : BlackIsZero
Image Description               : {"shape": [512, 640, 1]}
Strip Offsets                   : 600
Samples Per Pixel               : 1
Rows Per Strip                  : 512
Strip Byte Counts               : 655360
X Resolution                    : 1
Y Resolution                    : 1
Resolution Unit                 : None
Software                        : tifffile.py
Modify Date                     : 2022:10:27 17:40:15
Sample Format                   : Signed
Exif Version                    : 0232
Date/Time Original              : 2022:10:27 17:40:15
Create Date                     : 2022:10:27 17:40:15
Components Configuration        : Y, Cb, Cr, -
Flashpix Version                : 0100
Color Space                     : Uncalibrated
GPS Version ID                  : 2.3.0.0
GPS Latitude Ref                : North
GPS Latitude                    : 49 deg 42' 43.91"
GPS Longitude Ref               : West
GPS Longitude                   : 116 deg 45' 55.70"
GPS Altitude Ref                : Above Sea Level
GPS Altitude                    : 865.003003 m
GPS Status                      : Measurement Active
GPS Map Datum                   : WGS-84
Image Size                      : 640x512
Megapixels                      : 0.328
GPS Altitude                    : 865 m Above Sea Level
GPS Latitude                    : 49 deg 42' 43.91" N
GPS Longitude                   : 116 deg 45' 55.70" W
GPS Position                    : 49 deg 42' 43.91" N, 116 deg 45' 55.70" W

Extrapolating from that, performing the command while the tiff images are in a different file from the jpg images, but still sharing the same root directory, would the the command look something like this?
"C:\Program Files\ExifTool\exiftool.exe" -ext tiff -TagsFromFile "C:\Users\me\Desktop\Image_Conversion_Test\Test_Image_Dir\Raw_Test_Images"%-.5f.jpg -GPS:all -AllDates "C:\Users\me\Desktop\Image_Conversion_Test\Test_Image_Dir\Converted_Test_Images"

Thanks again for the help, your explanation really helped me wrap my brain around things.

StarGeek

Quote from: Dragonmaster150 on January 28, 2023, 03:42:23 PMOk, so if I'm understanding this right, using the -w command I can remove the added characters.

The -w option just details the various percent variables that exiftool uses.  You don't actually use it in this command.

QuoteExtrapolating from that, performing the command while the tiff images are in a different file from the jpg images, but still sharing the same root directory, would the the command look something like this?
"C:\Program Files\ExifTool\exiftool.exe" -ext tiff -TagsFromFile "C:\Users\me\Desktop\Image_Conversion_Test\Test_Image_Dir\Raw_Test_Images"%-.5f.jpg -GPS:all -AllDates "C:\Users\me\Desktop\Image_Conversion_Test\Test_Image_Dir\Converted_Test_Images"

Test it and see, but it looks correct. Myself, I would quote the source like this
"C:\Users\me\Desktop\Image_Conversion_Test\Test_Image_Dir\Raw_Test_Images%-.5f.jpg"
but that's just a matter of personal style.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype