Magick.NET: Slowdown in MagickImage.ToByteArray on arm64 Mac

Magick.NET version

Magick.NET-Q8-arm64 13.1.2

Environment (Operating system, version and so on)

arm64, Mac M1, .NET 7.0.11/7.0.401

Description

            using var image = new MagickImage(stream, new MagickReadSettings { Format = MagickFormat.Psd });
            image.ToByteArray();

takes minutes in 13.1.2 when it used to take seconds for a 3k/4k file of reasonable image complexity. All the additional time is in ToByteArray. In 13.1.2 there’s an overflow exception and in 13.1.0 the speed is as I expect.

I scaled the image down so I can attach it (if I can work out how to do that) and the perforce is 25ms for 13.1.0 and 4123ms for 13.1.2. Note: the slow down is less extreme when there is less detail in the image.

Steps to Reproduce

Create a PSD (RGB/8 is fine), make it say 1000 x 1000 and ensure it has some detail in it. Time the code above. Increase the image size and complexity to make the timing difference larger. My Mac has 64GB of RAM and an Apple M1 Max processor.

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 19 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for the file and I can see what is happening. I really think I should simplify the implementation of the ByteArrayWrapper.