This code creates invalid file:
var fi2 = new FileInfo(@"....\190132LCZ.psd");
IMagickImage image2 = new MagickImage(fi2);
image2.Resize(new MagickGeometry(-1, 200));
// following 2 lines causes to created invalid image
image2.Grayscale(PixelIntensityMethod.Average);
image2.Quantize(new QuantizeSettings
{
Colors = 256,
ColorSpace = ImageMagick.ColorSpace.Gray
});
image2.Depth = 8;
image2.ColorSpace = ColorSpace.Gray;
image2.Format = MagickFormat.Psd;
image2.AutoOrient();
image2.Write(@".......\22222.psd");
Such exception is thrown, when I try to call GetColorProfile on that 22222.psd file:
ImageMagick.MagickCorruptImageErrorException: 'insufficient image data in file `........\22222.psd' @ error/psd.c/ReadPSDImage/2413'
When I use image magick cli it shows different error though:
magick: unable to decompress image `......\22222_GrayScale.psd' @ error/psd.c/ReadPSDChannel/1442.
Original file:
https://drive.google.com/file/d/1LaKrxcZVmGAMhiMoAwo6kjzCpja9L31S/view
Thanks for reporting this. This seems to be an issue inside ImageMagick and I just pushed a patch to fix this. This will be resolved in the next version of Magick.NET.
@dlemstra Hi! thank you for the update. But after I updated to 7.14.0.2 I still have the same issue.
That's odd. Will take another look at this tonight.
I can reproduce your issue but and it looks to be related to the compression of the image. Will get back to you when I have more info.
EDIT: Found the issue, it was related to what I fixed earlier but I forgot something.