How can I pipe a MagickImageCollection
into a stream without loading it into memory?
#1375
-
I am working on a memory constrained system. Imagine I have 100 images I'm trying to write into a pdf, I can't load the entire pdf into memory I need it to be fully streamed. The API I'm imagining that I want would look like this: var stream = await blob.OpenWrite();
var collection = new MagickImageCollection();
collection.PipeTo(stream, MagickFormat.Pdf); // Can I do this somehow?
foreach(var imagePath in images)
{
await collection.Add(new MagickImage(stream)); // async add, wait till it writes fully to piped stream
}
await stream.FlushAsync(); The goal is to avoid loading the entire pdf and all images into memory simultaneously. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is not possible due to the design of the ImageMagick library and I also don't think it is a feature that would be easy to add. It might not even be possible. This is also because sometimes an image writer/encoder will iterate through the image multiple times and then the images would be decoded multiple times. |
Beta Was this translation helpful? Give feedback.
This is not possible due to the design of the ImageMagick library and I also don't think it is a feature that would be easy to add. It might not even be possible. This is also because sometimes an image writer/encoder will iterate through the image multiple times and then the images would be decoded multiple times.