Unsupported file format or not RAW file even with USE_DNGSDK

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

Forums: 

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.

0.505 Filename: ../../testfiles/unreadable.dng
0.505 Timestamp: Mon Aug 25 22:32:35 2025
0.505 Camera: Samsung SM-S908U ID: 0x0
0.505 Normalized Make/Model: =Samsung/SM-S908U= CamMaker ID: 59
0.505 UniqueCameraModel: =SM-S908U=
0.505  DNG Version: 1.7.0.0
0.505
0.505 EXIF:
0.505   MinFocal: 0.0 mm
0.505   MaxFocal: 0.0 mm
0.505   MaxAp @MinFocal: f/0.0
0.505   MaxAp @MaxFocal: f/0.0
0.505   CurFocal: 6.4 mm
0.505   MaxAperture @CurFocal: f/0.0
0.505   FocalLengthIn35mmFormat: 23 mm
0.505   LensMake:
0.505   Lens:
0.505
0.505
0.505 Makernotes:
0.505   DriveMode: -1
0.505   FocusMode: -1
0.505   MeteringMode: -1
0.505   AFPoint: -1
0.505   ExposureMode: -1
0.505   ExposureProgram: -1
0.505   ImageStabilization: -1
0.505   Lens:
0.505   LensFormat: 0,  LensMount: 43,  FocalType: 0, Undefined
0.505   LensFeatures_pre:
0.505   LensFeatures_suf:
0.505   MinFocal: 0.0 mm
0.505   MaxFocal: 0.0 mm
0.505   MaxAp @MinFocal: f/0.0
0.505   MaxAp @MaxFocal: f/0.0
0.505   MinAp @MinFocal: f/0.0
0.505   MinAp @MaxFocal: f/0.0
0.505   MaxAp: f/0.0
0.505   MinAp: f/0.0
0.505   CurFocal: 0.0 mm
0.505   CurAp: f/0.0
0.505   MaxAp @CurFocal: f/0.0
0.505   MinAp @CurFocal: f/0.0
0.505   TeleconverterID: 0
0.505   Teleconverter:
0.505   AdapterID: 0
0.505   Adapter:
0.505   AttachmentID: 0
0.505   Attachment:
0.505
0.505 ISO speed: 1000
0.505 Shutter: 1/24.0
0.505 Aperture: f/1.8
0.505 Focal length: 6.4 mm
0.505 Flash exposure compensation: 0.00 EV
0.505 Embedded ICC profile: no
0.505 Baseline exposure: 3.250
0.505 Number of raw images: 1
0.505 Thumb size:  4000 x 3000
0.505 Full size:   4000 x 3000
0.505 Image size:  4000 x 3000
0.505 Output size: 3000 x 4000
0.505 Image flip: 6
0.505 Raw colors: 3
0.505 Makernotes WB data:               coeffs                  EVs
0.505   As shot                   1.75043 1 1.91402 0    0.81  0.00  0.94  0.00
0.505
0.505 Camera2RGB matrix (mode: 1):
0.505 1.6887    -0.6238 -0.0649
0.505 -0.1948   1.3616  -0.1668
0.505 0.0022    -0.6410 1.6387
0.505
0.505 XYZ->CamRGB matrix:
0.505 0.0000    0.0000  0.0000
0.505 0.0000    0.0000  0.0000
0.505 0.0000    0.0000  0.0000
0.505
0.505 camRGB -> sRGB Matrix:
0.505 1.6887    -0.6238 -0.0649
0.505 -0.1948   1.3616  -0.1668
0.505 0.0022    -0.6410 1.6387
0.505
0.505 DNG Illuminant 1: D65
0.505 DNG Illuminant 2: Illuminant A
0.505 DNG color matrix 1:
0.505 0.8750    -0.1953 -0.1211
0.505 -0.4834   1.3740  0.0791
0.505 -0.1016   0.2666  0.4365
0.505
0.505 DNG color matrix 2:
0.505 1.7568    -0.9531 -0.1338
0.505 -0.3125   1.3408  0.0078
0.505 0.0068    0.1621  0.5195
0.505
0.505 DNG calibration matrix 1:
0.505 1.0322    0.0000  0.0000
0.505 0.0000    1.0000  0.0000
0.505 0.0000    0.0000  0.9814
0.505
0.505 DNG calibration matrix 2:
0.505 1.0322    0.0000  0.0000
0.505 0.0000    1.0000  0.0000
0.505 0.0000    0.0000  0.9814
0.505
0.505 DNG forward matrix 1:
0.505 0.6611    0.1611  0.1426
0.505 0.2363    0.7979  -0.0342
0.505 0.0059    -0.3340 1.1533
0.505
0.505 DNG forward matrix 2:
0.505 0.5020    0.2393  0.2236
0.505 0.0820    0.8564  0.0615
0.505 -0.1064   -0.7002 1.6309
0.505
0.505 Derived D65 multipliers: 1.920283 0.999304 1.578794

As mentioned in the README

As mentioned in the README.DNGSDK.txt file in the LibRaw distribution:

In your application
* create dng_host object (or derived object, e.g. with multithreaded) entity in your program;
* pass it to LibRaw via LibRaw::set_dng_host(dng_host *) call to enable DNG SDK use on runtime

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