Magick.NET icon indicating copy to clipboard operation
Magick.NET copied to clipboard

ImageMagick.MagickCoderErrorException: Unsupported file format or not RAW file `*' @ error/dng.c/ReadDNGImage/504

Open ilvira-dev opened this issue 6 months ago • 4 comments

Magick.NET version

14.6.0.0

Environment (Operating system, version and so on)

Win64

Description

Got excepton, with previous version 13.7. Then upgraded to latest 14.6.0.0 but got the same. Here is example file: DSCF6492.zip

2025-05-12 14:13:03,244 ERROR AppLog:92 - ImageMagick.MagickCoderErrorException: Unsupported file format or not RAW file C:/Users/username/AppData/Local/Temp/magick-9XkXeP6fxNxwffCtjdL3EzVsHOpsfOcX' @ error/dng.c/ReadDNGImage/504 at ImageMagick.NativeInstance.CheckException(IntPtr exception, IntPtr result) at ImageMagick.MagickImage.NativeMagickImage.ReadStream(IMagickSettings1 settings, ReadWriteStreamDelegate reader, SeekStreamDelegate seeker, TellStreamDelegate teller) at ImageMagick.MagickImage.Read(Stream stream, IMagickReadSettings1 readSettings, Boolean ping) at ImageMagick.MagickImage..ctor(Stream stream, IMagickReadSettings1 readSettings) at

Steps to Reproduce

static void Main(string[] args)
{
    string dngFilePath = @"c:\_imgTest\ProblematicDNGs\DSCF6492.dng";
    string outputDirectory = @"c:\U_imgTest\ProblematicDNGs\out";

    System.IO.Directory.CreateDirectory(outputDirectory);

    GenerateThumbnail(dngFilePath, outputDirectory, 300, 300);
    GenerateThumbnail(dngFilePath, outputDirectory, 1600, 1600);

    Console.WriteLine("Thumbnails generated successfully.");
}

static void GenerateThumbnail(string inputFilePath, string outputDirectory, uint width, uint height)
{
    using (var image = new MagickImage(inputFilePath)) // Exception is on this line
    {
        image.Resize(width, height);

        string outputFilePath = System.IO.Path.Combine(outputDirectory, $"thumbnail_{width}x{height}.jpg");

        image.Write(outputFilePath);

        Console.WriteLine($"Thumbnail saved: {outputFilePath}");
    }
}

Images

DSCF6492.zip

ilvira-dev avatar May 12 '25 14:05 ilvira-dev

It seems that your raw file uses jpeg-xl to compress the pixel data. But that is not yet supported by the libraw library that is being used to read the dng file.

dlemstra avatar May 12 '25 19:05 dlemstra

Thanks for the insight! Do you know if there's a workaround or another library that can extract a thumbnail from this format?

ilvira-dev avatar May 13 '25 12:05 ilvira-dev

There is no work around this just isn't supported by that library. I also don't know any libraries that already have support for reading this compression.

dlemstra avatar May 13 '25 12:05 dlemstra

Thank you for your time and work!

ilvira-dev avatar May 13 '25 12:05 ilvira-dev