Quantcast
Channel: magick Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 1011

Commented Unassigned: ToByteArray and Write(Stream) for MagickImageCollection kill application [1169]

$
0
0
I have been trying out Magick.NET in my web application with success until I attempted to create animated gifs. When I try to call `collection.ToByteArray()` or `collection.Write(stream)` the application crashes. No exception, just crashes.

Here is my simple function

```
public byte[] CreateWithImageMagic(Bitmap[] images) {
try {
using (var collection = new MagickImageCollection()) {
foreach (Bitmap t in images) {
var imageMagicItem = new MagickImage(t) { AnimationDelay = 100 };
collection.Add(imageMagicItem);
}

collection.Optimize();

using (var stream = new MemoryStream()) {
collection.ToByteArray(); // This call kills the app
collection.Write(stream); // This call kills the app

collection.ForEach(i => i.Dispose());
return stream.ToArray();
}
}
}
catch (Exception ex) {
throw ex;
}
}
```

If I use the `Write(String)` overload (path on disc) the code executes successfully and the animated gif is created. This is an ASP.NET MVC 4 application running .NET 4.5.1 and using the x86 build. Any ideas?
Comments: ** Comment from web user: posthope **

Corection to above:

I wanted to try `Format = MagickFormat.Jpg` but didn't work.


Viewing all articles
Browse latest Browse all 1011

Trending Articles