This project has moved and is read-only. For the latest updates, please go here.

Difference between opening through a path vs a stream

Nov 10, 2016 at 10:24 PM

I'm noticing some difference between using the MagickImage constructor with a path to the file vs a stream to the file. It seems like when I'm opening it with a stream, it's returning me the thumbnail version of the image, while opening with a fully qualified path returns me the full image. Is that expected?

Here's my code
byte[] fileBytes = File.ReadAllBytes(fileName);
MagickImageCollection collection;
using (var ms = new MemoryStream(fileBytes))
    collection = new MagickImage(ms);
Nov 10, 2016 at 11:06 PM
Can you share an image that I can use to reproduce the issue. It might produce a different result because it is unable to determine the image type.
Nov 11, 2016 at 3:27 PM
I used a NEF image, and I've seen it happen with 3FR images as well. Though I did manage to solve it by giving the constructor a setting and telling the library that the format is Nef.

Though it's still weird that giving it a full byte stream would cause it difficulties when a full file path doesn't have the issue. So if there's an explanation, it would still help with my understanding, and future debugging.

Either way, here's the specific file I was testing with:!xsxgiRYY!zsKfXNulzUV2rbbWN14zSL5U8lZdzdgVj_2AYy2m_2E
Nov 13, 2016 at 7:33 PM
ImageMagick will use the extension of the file to determine the format of the image. When you read an image from a stream it will use the first few bytes to determine the format. The first few bytes of a NEF image are the same as a TIFF image and when this is read with a TIFF reader it will read the thumbnail from the NEF image. As you have found out specifying the format in the settings will resolve your issue.