MagickImage.Write 0 size empty result

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
martin0
Posts: 10
Joined: 2016-11-03T03:40:30-07:00
Authentication code: 1151

MagickImage.Write 0 size empty result

Post by martin0 »

Hi,

I've got some code that uses MagickImage class.

The code used to work (I thought) so obviously something's changed, and I'm trying to troubleshoot the problem...

My code looks like this:

Code: Select all

                MemoryStream ms = null;
                MagickImage image = new MagickImage(data, readSettings);
                image.Format = MagickFormat.Bmp;// Png;//Bmp3;
                ms = new MemoryStream();
                image.Write(ms);
                image.Dispose(); image = null;
                byte[] result = ms.GetBuffer();

                ms.Dispose();
The issue is that after the
image.Write(ms);
the ms.Length is 0 even though the image is 2495x3501
No exception is thrown


Any ideas?
Thanks
Martin
martin0
Posts: 10
Joined: 2016-11-03T03:40:30-07:00
Authentication code: 1151

Re: MagickImage.Write 0 size empty result

Post by martin0 »

Slightly more information,
I'm trying to return a decoded image to a calling function.
I receive the encoded data, decode it by constructing the MagickImage, passing in encodeddata and readSettings.
use image.Write to save the decoded data.
The original data is MagickFormat.G4, CompressionMethod.Fax.
I note that when I call image.Write,
the Format is now MagickFormat.Bmp (because I set it), but the Compression is still Fax, because I haven't changed it to anything else.

Am I taking the right approach, given the requirement?

Weirdly the code works at normal runtime. It's just in test mode it fails.
I think it's something to do with timings/multi-threading. However, as it's so repeatable, I feel something needs fixing/explaining in the write method.

Thanks again
Martin
martin0
Posts: 10
Joined: 2016-11-03T03:40:30-07:00
Authentication code: 1151

Re: MagickImage.Write 0 size empty result

Post by martin0 »

I'm using Assembly Magick.NET-Q16-AnyCPU, Version=7.0.0.0
martin0
Posts: 10
Joined: 2016-11-03T03:40:30-07:00
Authentication code: 1151

Re: MagickImage.Write 0 size empty result

Post by martin0 »

I think I may have had a memory leak, leading to unexpected behaviour....
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: MagickImage.Write 0 size empty result

Post by dlemstra »

And your issue is now resolved?
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
martin0
Posts: 10
Joined: 2016-11-03T03:40:30-07:00
Authentication code: 1151

Re: MagickImage.Write 0 size empty result

Post by martin0 »

Hi,
Not yet, but I currently think the problem lies else where.
Happy to have it left with me, unless I come back.
I'll confirm if I resolve the problem - not currently full time on this, so unsure of timescales.
Martin
Post Reply