Magick.NET
Magick.NET copied to clipboard
ImageMagick.MagickCoderErrorException: Unsupported file format or not RAW file `*' @ error/dng.c/ReadDNGImage/504
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
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.
Thanks for the insight! Do you know if there's a workaround or another library that can extract a thumbnail from this format?
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.
Thank you for your time and work!