How to copy lens correction data to another image?

Started by KarlF12, November 20, 2023, 01:50:29 PM

Previous topic - Next topic

KarlF12

Good afternoon,

I have a set of 5 raw AEB images from my drone (Autel Evo II Pro v3). The lens correction data is embedded in the images, and the camera isn't in the lensfun database. This is fine for individual raw photos (all I have to do is turn on lens correction and it's fixed), but when I create a HDR, the lens correction info seems to get lost. The lens correction module of the HDR says "camera/lens not found."

Even if I apply the lens correction to all 5 images before creating the HDR, the HDR seems to be made from the original uncorrected images. I tried copying and pasting the lens correction from the history stack, but it just repeats the above error on the HDR.

This seems to be a known issue in DarkTable.  It was suggested to me as a workaround that I could copy the EXIF metadata from one of the source files to the HDR file and then apply the lens correction.  I've tried to do that like this:

exiftool -TagsFromFile MAX_0106.DNG -all:all MAX_0106-hdr.dng


And a few similar arrangements, but haven't been able to get it to work.  I re-add the image to DarkTable but it still says camera/lens not found.  I'm using DarkTable 4.4.1 and exiftool 11.88 (from WSL Ubuntu).

What can I do about this?

Phil Harvey

Can you post the exiftool -a -u -G1 output for both your HDR image and for one that contains the lens correction data?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: KarlF12 on November 20, 2023, 01:50:29 PMexiftool 11.88 (from WSL Ubuntu).

Also, upgrade exiftool.  That version is over 3½ years old.
"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

KarlF12

Phil, here is the original DNG EXIF, followed by the HDR EXIF, minus the GPS data.

[ExifTool]      ExifTool Version Number         : 11.88
[System]        File Name                       : MAX_0106.DNG
[System]        Directory                       : .
[System]        File Size                       : 38 MB
[System]        File Modification Date/Time     : 2023:11:18 16:42:52-06:00
[System]        File Access Date/Time           : 2023:11:20 16:58:45-06:00
[System]        File Inode Change Date/Time     : 2023:11:19 20:51:55-06:00
[System]        File Permissions                : rwxrwxrwx
[File]          File Type                       : DNG
[File]          File Type Extension             : dng
[File]          MIME Type                       : image/x-adobe-dng
[File]          Exif Byte Order                 : Little-endian (Intel, II)
[IFD0]          Subfile Type                    : Reduced-resolution image
[IFD0]          Image Width                     : 160
[IFD0]          Image Height                    : 120
[IFD0]          Bits Per Sample                 : 8 8 8
[IFD0]          Compression                     : JPEG
[IFD0]          Photometric Interpretation      : YCbCr
[IFD0]          Make                            : Autel Robotics
[IFD0]          Camera Model Name               : XL705
[IFD0]          Preview Image Start             : 156218
[IFD0]          Orientation                     : Horizontal (normal)
[IFD0]          Samples Per Pixel               : 3
[IFD0]          Rows Per Strip                  : 120
[IFD0]          Preview Image Length            : 5700
[IFD0]          Planar Configuration            : Chunky
[IFD0]          Software                        : V5.0.5.16
[IFD0]          Modify Date                     : 2023:11:18 16:42:52
[IFD0]          Y Cb Cr Coefficients            : 0.299 0.587 0.114
[IFD0]          Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
[IFD0]          Y Cb Cr Positioning             : Co-sited
[IFD0]          Reference Black White           : 0 255 128 255 128 255
[IFD0]          DNG Version                     : 1.4.0.0
[IFD0]          DNG Backward Version            : 1.3.0.0
[IFD0]          Unique Camera Model             : XL705
[IFD0]          Localized Camera Model          : XL705
[IFD0]          Color Matrix 1                  : 1.3007 -0.771 0.092 -0.1262 0.8047 0.3842 0.0122 0.0834 0.5144
[IFD0]          Color Matrix 2                  : 0.9945 -0.355 -0.0868 -0.2576 1.0944 0.1866 -0.0426 0.1697 0.5299
[IFD0]          Analog Balance                  : 1 1 1
[IFD0]          As Shot Neutral                 : 0.512 1 0.52459
[IFD0]          Baseline Exposure               : 0
[IFD0]          Baseline Noise                  : 3
[IFD0]          Baseline Sharpness              : 1.33
[IFD0]          Linear Response Limit           : 1
[IFD0]          Shadow Scale                    : 1
[IFD0]          Calibration Illuminant 1        : Standard Light A
[IFD0]          Calibration Illuminant 2        : D65
[IFD0]          Profile Name                    : XL705
[IFD0]          Profile Hue Sat Map Dims        : 30 25 1
[IFD0]          Profile Hue Sat Map Data 1      : (Binary data 38077 bytes, use -b option to extract)
[IFD0]          Profile Hue Sat Map Data 2      : (Binary data 38303 bytes, use -b option to extract)
[IFD0]          Profile Embed Policy            : Allow Copying
[IFD0]          Profile Copyright               : Autel Robotics
[IFD0]          Original Default Final Size     : 0 0
[IFD0]          Original Best Quality Size      : 0 0
[IFD0]          Original Default Crop Size      : undef undef
[IFD0]          Preview Image                   : (Binary data 5700 bytes, use -b option to extract)
[SubIFD]        Subfile Type                    : Full-resolution image
[SubIFD]        Image Width                     : 5472
[SubIFD]        Image Height                    : 3648
[SubIFD]        Bits Per Sample                 : 16
[SubIFD]        Compression                     : Uncompressed
[SubIFD]        Photometric Interpretation      : Color Filter Array
[SubIFD]        Strip Offsets                   : 276024
[SubIFD]        Samples Per Pixel               : 1
[SubIFD]        Rows Per Strip                  : 3648
[SubIFD]        Strip Byte Counts               : 39923712
[SubIFD]        Planar Configuration            : Chunky
[SubIFD]        CFA Repeat Pattern Dim          : 2 2
[SubIFD]        CFA Pattern 2                   : 0 1 1 2
[SubIFD]        CFA Plane Color                 : Red,Green,Blue
[SubIFD]        CFA Layout                      : Rectangular
[SubIFD]        Linearization Table             : (Binary data 382105 bytes, use -b option to extract)
[SubIFD]        Black Level Repeat Dim          : 2 2
[SubIFD]        Black Level                     : 200 200 200 200
[SubIFD]        White Level                     : 4095
[SubIFD]        Default Scale                   : 1 1
[SubIFD]        Default Crop Origin             : 0 0
[SubIFD]        Default Crop Size               : 5472 3648
[SubIFD]        Bayer Green Split               : 0
[SubIFD]        Anti Alias Strength             : 1
[SubIFD]        Best Quality Scale              : 1
[SubIFD]        Opcode List 2                   : FixVignetteRadial
[SubIFD]        Opcode List 3                   : WarpRectilinear
[SubIFD]        Default User Crop               : 0 0 1 1
[SubIFD1]       Subfile Type                    : Reduced-resolution image
[SubIFD1]       Image Width                     : 960
[SubIFD1]       Image Height                    : 640
[SubIFD1]       Bits Per Sample                 : 8 8 8
[SubIFD1]       Compression                     : JPEG
[SubIFD1]       Photometric Interpretation      : YCbCr
[SubIFD1]       Preview Image Start             : 161918
[SubIFD1]       Samples Per Pixel               : 3
[SubIFD1]       Rows Per Strip                  : 640
[SubIFD1]       Preview Image Length            : 114106
[SubIFD1]       Planar Configuration            : Chunky
[SubIFD1]       Y Cb Cr Coefficients            : 0.299 0.587 0.114
[SubIFD1]       Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
[SubIFD1]       Y Cb Cr Positioning             : Co-sited
[SubIFD1]       Reference Black White           : 0 255 128 255 128 255
[SubIFD1]       Preview Image                   : (Binary data 114106 bytes, use -b option to extract)
[XMP-x]         XMP Toolkit                     : XMP Core 5.5.0
[XMP-xmp]       Creator Tool                    : V5.0.5.16
[XMP-xmp]       Modify Date                     : 2023:11:18 16:42:52
[XMP-xmp]       Create Date                     : 2023:11:18 16:42:52
[XMP-photoshop] Date Created                    : 2023:11:18 16:42:52
[ExifIFD]       Exposure Time                   : 1/1050
[ExifIFD]       F Number                        : 2.8
[ExifIFD]       Exposure Program                : Program AE
[ExifIFD]       ISO                             : 100
[ExifIFD]       Exif Version                    : 0230
[ExifIFD]       Date/Time Original              : 2023:11:18 16:42:52
[ExifIFD]       Create Date                     : 2023:11:18 16:42:52
[ExifIFD]       Shutter Speed Value             : 1/1050
[ExifIFD]       Aperture Value                  : 2.8
[ExifIFD]       Exposure Compensation           : -1.4
[ExifIFD]       Max Aperture Value              : 2.8
[ExifIFD]       Metering Mode                   : Center-weighted average
[ExifIFD]       Light Source                    : Unknown
[ExifIFD]       Focal Length                    : 10.6 mm
[ExifIFD]       Exposure Mode                   : Auto
[ExifIFD]       White Balance                   : Auto
[ExifIFD]       Digital Zoom Ratio              : 1
[ExifIFD]       Contrast                        : Normal
[ExifIFD]       Saturation                      : Normal
[ExifIFD]       Sharpness                       : Normal
[GPS]           GPS Version ID                  : 2.3.0.0
[GPS]           GPS Latitude Ref                :
[GPS]           GPS Latitude                    :
[GPS]           GPS Longitude Ref               :
[GPS]           GPS Longitude                   :
[GPS]           GPS Altitude Ref                :
[GPS]           GPS Altitude                    :
[Composite]     Aperture                        : 2.8
[Composite]     CFA Pattern                     : [Red,Green][Green,Blue]
[Composite]     Image Size                      : 5472x3648
[Composite]     Megapixels                      : 20.0
[Composite]     Shutter Speed                   : 1/1050
[Composite]     GPS Altitude                    :
[Composite]     GPS Latitude                    :
[Composite]     GPS Longitude                   :
[Composite]     Focal Length                    : 10.6 mm
[Composite]     GPS Position                    :
[Composite]     Light Value                     : 13.0

[ExifTool]      ExifTool Version Number         : 11.88
[System]        File Name                       : MAX_0106-hdr.dng
[System]        Directory                       : .
[System]        File Size                       : 76 MB
[System]        File Modification Date/Time     : 2023:11:20 16:58:46-06:00
[System]        File Access Date/Time           : 2023:11:20 16:58:47-06:00
[System]        File Inode Change Date/Time     : 2023:11:20 16:58:46-06:00
[System]        File Permissions                : rwxrwxrwx
[File]          File Type                       : DNG
[File]          File Type Extension             : dng
[File]          MIME Type                       : image/x-adobe-dng
[File]          Exif Byte Order                 : Big-endian (Motorola, MM)
[IFD0]          Subfile Type                    : Full-resolution image
[IFD0]          Image Width                     : 5472
[IFD0]          Image Height                    : 3648
[IFD0]          Bits Per Sample                 : 32
[IFD0]          Compression                     : Uncompressed
[IFD0]          Photometric Interpretation      : Color Filter Array
[IFD0]          Image Description               :
[IFD0]          Make                            : Autel Robotics
[IFD0]          Camera Model Name               : XL705
[IFD0]          Strip Offsets                   : 1240
[IFD0]          Orientation                     : Horizontal (normal)
[IFD0]          Samples Per Pixel               : 1
[IFD0]          Rows Per Strip                  : 3648
[IFD0]          Strip Byte Counts               : 79847424
[IFD0]          Planar Configuration            : Chunky
[IFD0]          Software                        : darktable 4.4.1
[IFD0]          Modify Date                     : 2023:11:20 16:58:45
[IFD0]          Sample Format                   : Float
[IFD0]          Rating                          : 1
[IFD0]          CFA Repeat Pattern Dim          : 2 2
[IFD0]          CFA Pattern 2                   : 0 1 1 2
[IFD0]          Copyright                       :
[IFD0]          Date/Time Original              : 2023:11:18 16:42:52
[IFD0]          DNG Version                     : 1.2.0.0
[IFD0]          DNG Backward Version            : 1.1.0.0
[IFD0]          Unique Camera Model             : XL705
[IFD0]          Localized Camera Model          : XL705
[IFD0]          White Level                     : 1065353216
[IFD0]          Default Crop Origin             : 0 0
[IFD0]          Default Crop Size               : 5472 3648
[IFD0]          Color Matrix 1                  : 0.9945 -0.355 -0.0868 -0.2576 1.0944 0.1866 -0.0426 0.1697 0.5299
[IFD0]          As Shot Neutral                 : 0.512 1 0.52459
[IFD0]          Calibration Illuminant 1        : D65
[IFD0]          Active Area                     : 0 0 3648 5472
[IFD0]          Original Default Final Size     : 0 0
[IFD0]          Original Best Quality Size      : 0 0
[IFD0]          Original Default Crop Size      : undef undef
[ExifIFD]       Exposure Time                   : 1/1050
[ExifIFD]       F Number                        : 2.8
[ExifIFD]       Exposure Program                : Program AE
[ExifIFD]       ISO                             : 100
[ExifIFD]       Exif Version                    : 0230
[ExifIFD]       Date/Time Original              : 2023:11:18 16:42:52
[ExifIFD]       Create Date                     : 2023:11:18 16:42:52
[ExifIFD]       Shutter Speed Value             : 1/1050
[ExifIFD]       Aperture Value                  : 2.8
[ExifIFD]       Exposure Compensation           : -1.4
[ExifIFD]       Max Aperture Value              : 2.8
[ExifIFD]       Metering Mode                   : Center-weighted average
[ExifIFD]       Light Source                    : Unknown
[ExifIFD]       Focal Length                    : 10.6 mm
[ExifIFD]       Color Space                     : Uncalibrated
[ExifIFD]       Exposure Mode                   : Auto
[ExifIFD]       White Balance                   : Auto
[ExifIFD]       Digital Zoom Ratio              : 1
[ExifIFD]       Contrast                        : Normal
[ExifIFD]       Saturation                      : Normal
[ExifIFD]       Sharpness                       : Normal
[GPS]           GPS Version ID                  : 2.2.0.0
[GPS]           GPS Latitude Ref                :
[GPS]           GPS Latitude                    :
[GPS]           GPS Longitude Ref               :
[GPS]           GPS Longitude                   :
[GPS]           GPS Altitude Ref                :
[GPS]           GPS Altitude                    :
[Composite]     Aperture                        : 2.8
[Composite]     CFA Pattern                     : [Red,Green][Green,Blue]
[Composite]     Image Size                      : 5472x3648
[Composite]     Megapixels                      : 20.0
[Composite]     Shutter Speed                   : 1/1050
[Composite]     GPS Altitude                    :
[Composite]     GPS Latitude                    :
[Composite]     GPS Longitude                   :
[Composite]     Focal Length                    : 10.6 mm
[Composite]     GPS Position                    :
[Composite]     Light Value                     : 13.0

I know this version of exiftool is old, it's just what was in the WSL Ubuntu repo.  I can update it if that'll help.

Phil Harvey

My guess is that the lens correction is stored in the OpcodeList tags of the original DNG:

[SubIFD]        Opcode List 2                   : FixVignetteRadial
[SubIFD]        Opcode List 3                   : WarpRectilinear

The main image is in the SubIFD of the original image, but in IFD0 of the HDR image.  Your command wouldn't have worked because it tried to copy tags to the same location in the destination (plus the OpcodeList tags are flagged to "Avoid", so they wouldn't be copied with -all:all anyway).

Try this:

exiftool -TagsFromFile MAX_0106.DNG "-ifd0:opcodelist2<opcodelist2" "-ifd0:opcodelist3<opcodelist3" -n MAX_0106-hdr.dng

or equivalently

exiftool -TagsFromFile MAX_0106.DNG "-ifd0:all<opcodelist2" "-ifd0:all<opcodelist3" -n MAX_0106-hdr.dng

Note that the -n is necessary because only the "numerical" (ie. unconverted) values of these tags may be written.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

KarlF12

Quote from: Phil Harvey on November 20, 2023, 09:00:26 PMor equivalently

exiftool -TagsFromFile MAX_0106.DNG "-ifd0:all<opcodelist2" "-ifd0:all<opcodelist3" -n MAX_0106-hdr.dng

I did go ahead and change over from the WSL exiftool to version 12.70 for Windows.  I got this:

exiftool(-k).exe -TagsFromFile MAX_0106.DNG "-ifd0:all<opcodelist2" "-ifd0:all<opcodelist3" -n MAX_0106-hdr.dng
Warning: [Minor] Not decoding some large array(s). Ignore minor errors to decode - MAX_0106.DNG
    1 image files updated

That seems to have done the trick!  I'm able to apply lens correction from metadata to the HDR image now.  Thanks so much for that.  This has been a perplexing problem because DarkTable will not do the HDR merge if it's in any other format.  I'll make a note of this because I'll probably have to do it many times.

Phil Harvey

The warning you see is likely due to the large LinearizationTable, but you can safely disregard this warning because you aren't copying this information.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).