Hi,
We are using magick.net for getting some image informations (get colorspace, bit per sample, etc.) and in some case, we have to transform the same files (dropped in our main app) to tiff. For getting info, we use the code below. On opening large Tiff (>2GB Tiff), we get instantly an OverflowException, Arithmetic operation resulted in an overflow. at ImageMagick.MagickReader.Read(Stream stream)
Any idea we can overcome this. We currently use the V6 of magick.net. Q8 - X64
The whole project is X64 based, not anyCpu.
```
FileStream imageStream = new FileStream(TiffFile, FileMode.Open, FileAccess.Read);
MagickImage currentImage;
ImageMagick.ColorSpace orgColorspace;
try
{
currentImage = new MagickImage(imageStream);
orgColorspace = currentImage.ColorSpace;
if (currentImage.ReadWarning != null)
{
log.Info("RipTiff : Warning on opening file : " + TiffFile + " : " + currentImage.ReadWarning.Message);
}
}
```
Comments: I did not realize you would run into a memory boundary when you use a stream instead of a file. The stream exceeds the maximum size (https://msdn.microsoft.com/en-us/library/hh285054(v=vs.110).aspx). Reading directly from file is better than reading from a filestream. When you read from a filestream the Magick.NET code will first put the file data in a byte array. This means that your application will probably use a lot of memory. It will probably be faster to read from file directly anyways. I modified the Magick.NET code to throw an exception when the stream size exceeds the maximum length of a byte array.
We are using magick.net for getting some image informations (get colorspace, bit per sample, etc.) and in some case, we have to transform the same files (dropped in our main app) to tiff. For getting info, we use the code below. On opening large Tiff (>2GB Tiff), we get instantly an OverflowException, Arithmetic operation resulted in an overflow. at ImageMagick.MagickReader.Read(Stream stream)
Any idea we can overcome this. We currently use the V6 of magick.net. Q8 - X64
The whole project is X64 based, not anyCpu.
```
FileStream imageStream = new FileStream(TiffFile, FileMode.Open, FileAccess.Read);
MagickImage currentImage;
ImageMagick.ColorSpace orgColorspace;
try
{
currentImage = new MagickImage(imageStream);
orgColorspace = currentImage.ColorSpace;
if (currentImage.ReadWarning != null)
{
log.Info("RipTiff : Warning on opening file : " + TiffFile + " : " + currentImage.ReadWarning.Message);
}
}
```
Comments: I did not realize you would run into a memory boundary when you use a stream instead of a file. The stream exceeds the maximum size (https://msdn.microsoft.com/en-us/library/hh285054(v=vs.110).aspx). Reading directly from file is better than reading from a filestream. When you read from a filestream the Magick.NET code will first put the file data in a byte array. This means that your application will probably use a lot of memory. It will probably be faster to read from file directly anyways. I modified the Magick.NET code to throw an exception when the stream size exceeds the maximum length of a byte array.