As you pointed yourself, the ImageTypeCheck.getImageType
method is closing the stream.
How were you supposed to find the issue?
- The error message clearly indicates that the stream has been disposed. All that left was finding the culprit.
- The callstack shows that the
ImageTools.IO.Gif.GifDecoder.Decode
was being called when the error was thrown. So it happened before that. - Luckily, there's only one method using the stream before the GifDecoder, and that is
ImageTypeCheck.getImageType
To fix the issue, just remove the stream.Close
from the ImageTypeCheck.getImageType
method, and replace it with a Seek
to go back to the beginning of the stream (the GifDecoder expects the stream to be positioned at the start of the picture).
stream.Seek(0, SeekOrigin.Begin);