Page 1 of 1

MagickImage.Write 0 size empty result

Posted: 2017-04-26T06:41:16-07:00
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

Re: MagickImage.Write 0 size empty result

Posted: 2017-04-26T06:56:11-07:00
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

Re: MagickImage.Write 0 size empty result

Posted: 2017-04-26T07:02:03-07:00
by martin0
I'm using Assembly Magick.NET-Q16-AnyCPU, Version=7.0.0.0

Re: MagickImage.Write 0 size empty result

Posted: 2017-04-27T02:53:13-07:00
by martin0
I think I may have had a memory leak, leading to unexpected behaviour....

Re: MagickImage.Write 0 size empty result

Posted: 2017-04-27T06:20:07-07:00
by dlemstra
And your issue is now resolved?

Re: MagickImage.Write 0 size empty result

Posted: 2017-04-27T08:57:40-07:00
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