Hi !
Everytime I run the following code on the specified PNG image I get "ImageMagick.MagickCoderErrorException : 'IDAT: CRC error `' @ error/png.c/MagickPNGErrorHandler/1715'".
I searched for this issue in this repository, on GitHub, on StackOverflow and everywhere on Google but I can't find anything useful regarding "ImageMagick.MagickCoderErrorException", "IDAT: CRC error" nor "error/png.c/MagickPNGErrorHandler/1715", so I post it here.
using ImageMagick;
using System.Net;
namespace MagickCRCError
{
internal class Program
{
private static void Main(string[] args)
{
byte[] data;
using (WebClient client = new WebClient())
{
data = client.DownloadData("https://www.muenzeoesterreich.at/var/em_plain_site/storage/images/_aliases/product_full/media/bilder/produktbilder/2.sammeln/2.2.5_euro/5e_2018_osterhase_set/3970854-2-ger-DE/5e_2018_osterhase_set.png");
}
MagickImage image = new MagickImage(data);
image.BackgroundColor = MagickColors.White;
}
}
}
It's probably an issue from the PNG itself (CRC Error) but I can open it in any web browser or image viewer so it's a bit weird to me.
Feel free to close this issue if I have missed something.
Anyway, thanks for developing Magick.Net !
The ImageMagick library that is being used by Magick.NET is very strict about the PNG file being valid. And it appears that your file is not valid. There is an option to disable CRC checking and I should add that to the PngReadDefines but I tried that on the command line and it then still fails to read the file. Other programs can read the image because they are less strict about the contents of the file and probably ignore a lot of information that is still being read by ImageMagick.
Thanks for you answer !
I just added a check for ImageMagick.MagickCoderErrorException in my code and everything goes fine.
How to disable to option CRC in code C#?
I just did
try
{
//Magick stuff here
}
catch (MagickCoderErrorException e)
{
//Stuff didn't work because a CRC error occured
}
Thank's!!!
Em qui., 12 de mar. de 2020 às 16:52, Raf notifications@github.com
escreveu:
I just did
try
{
//Magick stuff here
}catch (MagickCoderErrorException e)
{
//Stuff didn't work because a CRC error occured
}—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/dlemstra/Magick.NET/issues/562#issuecomment-598383737,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AGGSZLNRFT2HLD3RNHGV7CDRHE4RNANCNFSM4KJT3NIA
.
@dlemstra Apolgies for the necro-thread but I have the same issue.
As per @LucasStark95 comment above, what is the correct method of disabling the CRC check to avoid the "MagickPNGErrorHandler/1715" error? I can't work it out from scanning the source easily.
Simply wrapping in an exception handler as per above only stops errors bubbling up.
I have tried:
var defs = new PngReadDefines()
{
IgnoreCrc = true,
};
and applying this to all my images like:
image1.Settings.SetDefines(defs);
image2.Settings.SetDefines(defs);
diffImage.Settings.SetDefines(defs);
But this line diffImage.Write(diffPath);
still fails with the exception {"WriteBlob Faileddiff.png' @ error/png.c/MagickPNGErrorHandler/1715"}`
This only happens when I edit one of the PNG files manually rather than them being PNG ouput from ImageMagick.
Could you create a new issue @Wabbbit and explain in more detail (with a test image) the issue that you are experiencing?
Most helpful comment
The ImageMagick library that is being used by Magick.NET is very strict about the PNG file being valid. And it appears that your file is not valid. There is an option to disable CRC checking and I should add that to the
PngReadDefinesbut I tried that on the command line and it then still fails to read the file. Other programs can read the image because they are less strict about the contents of the file and probably ignore a lot of information that is still being read by ImageMagick.