-
-
Notifications
You must be signed in to change notification settings - Fork 444
Description
Magick.NET version
14.10.2
Environment (Operating system, version and so on)
Windows 11 Business 25H2
Description
This has been happening for a while on different versions, but not frequent enough for me to log as a bug until now. Always thought it might be down to the image used but it's happened enough now I figure it must be a bug.
When using the ImageOptimizer class and running an image through 'Compress', a fatal error is thrown with certain image files, causing my .NET service to crash and subsequently repeatedly attempt to process the image over and over.
I've attached minimal reproduce steps below and a copy of an image I found to error. The fatal error thrown is:
0xC0000005
at ImageMagick.ImageOptimizers.JpegOptimizer+NativeMethods.JpegOptimizer_CompressFile(IntPtr, IntPtr, Boolean, Boolean, UIntPtr, IntPtr ByRef)
at ImageMagick.ImageOptimizers.JpegOptimizer+NativeJpegOptimizer.CompressFile(System.String, System.String, Boolean, Boolean, UIntPtr)
at ImageMagick.ImageOptimizers.JpegOptimizer.DoNativeCompress(System.String, System.String, Boolean, Boolean, UInt32)
at ImageMagick.ImageOptimizers.JpegOptimizer.DoCompress(System.IO.FileInfo, Boolean, UInt32)
at ImageMagick.ImageOptimizers.JpegOptimizer.Compress(System.IO.FileInfo, UInt32)
at ImageMagick.ImageOptimizers.JpegOptimizer.Compress(System.IO.FileInfo)
at ImageMagick.ImageOptimizer.DoCompress(System.IO.FileInfo)
at ImageMagick.ImageOptimizer.Compress(System.String)
at Program.<Main>$(System.String[])
Steps to Reproduce
Create a fresh console app running .NET 10 (also occurs on earlier versions of .NET). Install Magick.NET, using any of the following i've replicated it with:
- magick.net-q16-hdri-anycpu
- magick.net-q16-hdri-x64
- magick.net-q16-anycpu
Here's the console app code:
using ImageMagick;
var filePath = Path.Combine(Environment.CurrentDirectory, "test_image.jpg");
new ImageOptimizer().Compress(filePath);
