-
Hi, thanks for creating such a nice library! I tried various things with Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
That should be possible? Can you show what you have tried so far and where it fails? You should add the images to the |
Beta Was this translation helpful? Give feedback.
-
Thanks for the fast response! I think I am simply struggling to use the collection API properly. Here is some code that works partially (it exports a PDF, but with only one page). async function processImages(files: FileList) {
const collection = MagickImageCollection.create();
for (let i = 0; i < files.length; i++) {
const arrayBuffer = await files[i].arrayBuffer();
const array = new Uint8Array(arrayBuffer);
// Probably wrong?
collection.read(array);
}
collection.write(
(output) => downloadBlob(output, 'test.pdf', 'application/octet-stream'),
MagickFormat.Pdf
);
} I also tried to use I'm pretty sure there is an obvious solution for this, but I couldn't find a matching example in the docs / test code. |
Beta Was this translation helpful? Give feedback.
-
Maybe the potential new method could be called Kudos for the API and Typescript definitions, this is really a joy to use. And super cool to have this locally in the browser 🚀 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
I was suspecting that this was happening. And you are correct about the
collection.read(array);
line. You will need to read and an image and add it without disposing it. You can do that withcollection.push(MagickImage.Create(array))
. But I should probably add an extra method where you can just docollection.newMethod(array)
. But what method name would you expect for this?