I apologize in advance as my understanding of DNGs is very poor, but I thought that building the Adobe DNG SDK and building libraw with USE_DNGSDK and libjxl would allow it to unpack my phone's DNGs.
However, perhaps I was mistaken as it still complains "Unsupported file format or not RAW file" when I tried to open it with ImageMagick or the mem_image sample.
I published a reproducable repo here: https://github.com/PseudoResonance/immich-base-images/tree/dng
run-dng-test.sh
contains the necessary Docker build command to compile the image up to the libraw stage, then runs a test script to execute mem_image on the provided sample image. (Note the sample image is just one I found online that seems similar to my phone image and exhibits the same issue.)
The build scripts are under server/sources
and shows how libjxl, libdng and libraw were built.
Here's the full identify output on the image.
0.619 Filename: ../../testfiles/_A7F9420-HDR.dng
0.619 Timestamp: Thu Sep 19 18:56:11 2024
0.619 Camera: Sony ILCE-7M4 ID: 0x0
0.619 Normalized Make/Model: =Sony/ILCE-7M4= CamMaker ID: 63
0.619 UniqueCameraModel: =Sony ILCE-7M4=
0.619 RawDataUniqueID: =b����K�%g��_�=
0.619 DNG Version: 1.7.0.0
0.619
0.619 EXIF:
0.619 MinFocal: 24.0 mm
0.619 MaxFocal: 70.0 mm
0.619 MaxAp @MinFocal: f/2.8
0.619 MaxAp @MaxFocal: f/2.8
0.619 CurFocal: 37.0 mm
0.619 MaxAperture @CurFocal: f/2.8
0.619 FocalLengthIn35mmFormat: 37 mm
0.619 LensMake:
0.619 Lens: FE 24-70mm F2.8 GM
0.619
0.619
0.619 Makernotes:
0.619 DriveMode: -1
0.619 FocusMode: -1
0.619 MeteringMode: -1
0.619 AFPoint: -1
0.619 ExposureMode: -1
0.619 ExposureProgram: -1
0.619 ImageStabilization: -1
0.619 Lens:
0.619 LensFormat: 0, LensMount: 0, FocalType: 0, Undefined
0.619 LensFeatures_pre:
0.619 LensFeatures_suf:
0.619 MinFocal: 0.0 mm
0.619 MaxFocal: 0.0 mm
0.619 MaxAp @MinFocal: f/0.0
0.619 MaxAp @MaxFocal: f/0.0
0.619 MinAp @MinFocal: f/0.0
0.619 MinAp @MaxFocal: f/0.0
0.619 MaxAp: f/0.0
0.619 MinAp: f/0.0
0.619 CurFocal: 0.0 mm
0.619 CurAp: f/0.0
0.619 MaxAp @CurFocal: f/0.0
0.619 MinAp @CurFocal: f/0.0
0.619 TeleconverterID: 0
0.619 Teleconverter:
0.619 AdapterID: 0
0.619 Adapter:
0.619 AttachmentID: 0
0.619 Attachment:
0.619
0.619 ISO speed: 6400
0.619 Shutter: 1/500.0
0.619 Aperture: f/3.5
0.619 Focal length: 37.0 mm
0.619 Flash exposure compensation: 0.00 EV
0.619 Embedded ICC profile: no
0.619 Baseline exposure: 1.350
0.619 Number of raw images: 1
0.619 Thumb size: 256 x 171
0.619 Full size: 7008 x 4672
0.619 Image size: 7008 x 4672
0.619 Output size: 7008 x 4672
0.619 Image flip: 0
0.619 Raw colors: 3
0.619 Highlight linearity limits: 32768 32768 32768 32768
0.619 Makernotes WB data: coeffs EVs
0.619 As shot 2.2002 1 1.56738 0 1.14 0.00 0.65 0.00
0.619
0.619 Camera2RGB matrix (mode: 1):
0.619 1.6361 -0.4486 -0.1874
0.619 -0.1152 1.4890 -0.3738
0.619 -0.0047 -0.3236 1.3283
0.619
0.619 XYZ->CamRGB matrix:
0.619 0.7460 -0.2365 -0.0588
0.619 -0.5687 1.3442 0.2474
0.619 -0.0624 0.1156 0.6584
0.619
0.619 camRGB -> sRGB Matrix:
0.619 1.6361 -0.4486 -0.1874
0.619 -0.1152 1.4890 -0.3738
0.619 -0.0047 -0.3236 1.3283
0.619
0.619 DNG Illuminant 1: Illuminant A
0.619 DNG Illuminant 2: D65
0.619 DNG color matrix 1:
0.619 0.8784 -0.4791 0.1177
0.619 -0.3468 1.0693 0.3213
0.619 0.0009 0.0507 0.7395
0.619
0.619 DNG color matrix 2:
0.619 0.7460 -0.2365 -0.0588
0.619 -0.5687 1.3442 0.2474
0.619 -0.0624 0.1156 0.6584
0.619
0.619 DNG calibration matrix 1:
0.619 0.9988 0.0000 0.0000
0.619 0.0000 1.0000 0.0000
0.619 0.0000 0.0000 0.9641
0.619
0.619 DNG calibration matrix 2:
0.619 0.9988 0.0000 0.0000
0.619 0.0000 1.0000 0.0000
0.619 0.0000 0.0000 0.9641
0.619
0.619 DNG forward matrix 1:
0.619 0.4743 0.3796 0.1104
0.619 0.2023 0.7673 0.0304
0.619 0.0553 0.0008 0.7690
0.619
0.619 DNG forward matrix 2:
0.619 0.5465 0.2614 0.1563
0.619 0.3232 0.6292 0.0475
0.619 0.1339 0.0025 0.6887
0.619
0.619 Derived D65 multipliers: 2.450757 0.931928 1.341527
Updated with phone photo
I got a proper photo from my phone that I added to the repository now and set it as the default file to be tested with the script.
As mentioned in the README
As mentioned in the README.DNGSDK.txt file in the LibRaw distribution:
mem_image sample does not have this pieces of code, so please test with dcraw_emu -dngsdk
-- Alex Tutubalin @LibRaw LLC
Thank you!
Oh... Can't believe I didn't think of that. Exported a TIFF first try with
/usr/src/app/libraw/bin/dcraw_emu -dngsdk -T -Z out.tiff /usr/src/app/testfiles/unreadable.dng
.I'm assuming then that the reason it didn't actually work in ImageMagick is because their DNG code is missing support for it? https://github.com/ImageMagick/ImageMagick/blob/main/coders/dng.c
I don't see the dng_host object in here. That's all that is required to allow unpacking these DNGs right? I'm already compiling against the working libraw and ImageMagick has other DNG reading code, but is just missing the dng_host for the Adobe DNG SDK?
Thank you very much for the incredibly fast response though!
Sorry, know nothing about
Sorry, know nothing about ImageMagick internals.
-- Alex Tutubalin @LibRaw LLC