Magick.net: Grayscale and Quantize on PSD generates corrupted file

Created on 26 Jun 2019  路  4Comments  路  Source: dlemstra/Magick.NET

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have verified that I am using the latest version of Magick.NET
  • [x] I have searched open and closed issues to ensure it has not already been reported

Description

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

  • Magick.NET version: 7.14.0.1
bug upstream

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zygimantaskazlauskas picture zygimantaskazlauskas  路  3Comments

MiyamuraMiyako picture MiyamuraMiyako  路  6Comments

danpetitt picture danpetitt  路  6Comments

Webreaper picture Webreaper  路  4Comments

VanillaChai picture VanillaChai  路  9Comments