Load image from Stream
See original GitHub issueMagick.NET-Q16-AnyCPU v7.11.1
I load from net image and try create “MagickImage”, but i catch next error:
using (var httpResponseStream = await httpResponse.Content.ReadAsStreamAsync())
{
using (var image = new MagickImage(httpResponseStream))
{
var size = new MagickGeometry(width, height);
image.Resize(size);
image.Format = MagickFormat.Jpg;
image.Write(outStream);
}
}
ImageMagick.MagickCoderErrorException: TIFF directory is missing required "ImageLength" field. `MissingRequired' @ error/tiff.c/TIFFErrors/656
at ImageMagick.NativeInstance.CheckException(IntPtr exception, IntPtr result)
at ImageMagick.MagickImage.NativeMagickImage.ReadStream(MagickSettings settings, ReadWriteStreamDelegate reader, SeekStreamDelegate seeker, TellStreamDelegate teller)
at ImageMagick.MagickImage.Read(Stream stream, MagickReadSettings readSettings, Boolean ping)
If I load “MagickImage” from a file then there is no such error:
using (var image = new MagickImage(path))
{
var size = new MagickGeometry(width, height);
image.Resize(size);
image.Format = MagickFormat.Jpg;
image.Write($"{path}_{image.Width}x{image.Height}.jpg");
}
I split file on part, please remove “zip” in the end.
sony_a7_iii_01.001.zip sony_a7_iii_01.002.zip sony_a7_iii_01.003.zip sony_a7_iii_01.004.zip
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Image.FromStream Method (System.Drawing)
Creates an Image from the specified data stream, optionally using embedded color management information and validating the image data.
Read more >c# - How to convert System.IO.Stream into an Image?
Bitmap image = new Bitmap(streamF); ConsoleWriteImage(image); //REMEMBER = in console App you must use < using System.Drawing; > //to handle ...
Read more >Load Image | Documents for Imaging .NET Edition
To load an image from stream, instantiate the FileStream class to read the image in the stream and load the file in GcBitmap...
Read more >Load Image from Stream
To load an image from a memory or file stream, use the ImageX.FromStream methods. When called, the FromStream methods store a copy of...
Read more >Image.FromStream: load image from stream - C# / C Sharp
4. Clone Image ; 5. Get Image Resolution and Image size and Display size ; 6. Draw image based on its size ;...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ImageMagick will try to guess the file format because you are reading from a stream and guesses that your file is a TIFF file. When reading from file it sees the
.arw
extension and knows your file is a RAW file. If you want to read from a stream you will need to tell Magick.NET the format of the file:@dlemstra thank you, it works.