14

I'm trying to add unit tests to the .Net ImageProcessor library: https://github.com/cosmo0/ImageProcessor/tree/tests

I'm working on Xamarin/Mono on my Mac. Mono seems to have a few problems with animated gifs images.
For my unit tests, I have a bunch of test images, and I load them all and run transformations on each of them. Each time I apply a filter (brightness for instance), it fails when trying to re-create an image.

The failing line is here : https://github.com/cosmo0/ImageProcessor/blob/tests/src/ImageProcessor/Imaging/Formats/GifFormat.cs#L95

It's just an Image.FromStream(stream);. I'm guessing the stream is wrong ; I tried to save it to a file, and indeed the file is not readable by the image viewer. The weird thing is that on Windows, it seems to be passing the tests perfectly fine: https://ci.appveyor.com/project/cosmo0/imageprocessor

Any idea what I could do to check the stream or fix it ?

Thanks !

6
  • 1
    Just a data point: TestApplyEffectBrightness on format-Penguins.gif seems to work okay on linux.
    – Jester
    Jun 30, 2014 at 15:28
  • 2
    Hey @jester I'm the author of the library. Thanks for testing. To clarify, it's animated gifs that are the issue. If you have the means to test/debug that it would be amazing. I only have a windows box so I can't debug as I can't get Xamarin to work with Mono. Jun 30, 2014 at 19:35
  • With format-animated.gif I get exception from OctreeQuantizer.cs line 534 but that seems to be a different problem.
    – Jester
    Jun 30, 2014 at 22:59
  • Hmmm.. That's a worry. I wish it all just worked like it does on Windows! Jul 1, 2014 at 16:57
  • 1
    throw new ArgumentException("Didn't expect this!"); Hah! not the best exception message. Aug 25, 2014 at 13:43

1 Answer 1

1

Try to reset the stream before calling

Image.FromStream(stream)

like this :

stream.Seek(0, SeekOrigin.Begin);

2
  • 3
    There's already a stream.Position = 0; isn't that the same ?
    – thomasb
    Aug 25, 2014 at 15:38
  • 1
    Wouldn't you need to flush as well? Serious question.
    – Novaterata
    Sep 30, 2014 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.