Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initializeImageMagick using UInt8Array of WASM Module #87

Closed
theomarkkuspaul opened this issue May 20, 2023 · 2 comments
Closed

initializeImageMagick using UInt8Array of WASM Module #87

theomarkkuspaul opened this issue May 20, 2023 · 2 comments
Milestone

Comments

@theomarkkuspaul
Copy link

theomarkkuspaul commented May 20, 2023

magick-wasm version

0.0.21

Description

This example is for the browser environment

Curious how to initialize the ImageMagick WASM module by fetch-ing the magick.wasm file, then converting that into an UInt8Array, before passing that data into the initializeImageMagick function.

It would appear the initialization function supports the magick.wasm file as an 8-bit array as defined here, but running this in the browser doesn't appear to be working for me.

Here's a rudimentary example of what I mean:

import {
    initializeImageMagick,
} from "@imagemagick/magick-wasm";

(async () => {
    const wasmLocation = new URL('http://localhost:7000/magick.wasm').href;  // basic web server using the `http-server` npm package
    const wasmResponse = await fetch(wasmLocation);
    const wasmBuffer = await wasmResponse.arrayBuffer();
    const wasmBytes = new Uint8Array(wasmBuffer);

    await initializeImageMagick(wasmBytes);
})();

Console gives me this error Uncaught (in promise) TypeError: t.startsWith is not a function.

Bundling using esbuild, not sure that's doing anything strange or not.

For what it's worth, passing a URL as the wasm location into initializeImageMagick imports the wasm module fine.

AKA

(async () => {
    const wasmLocation = new URL('http://localhost:7000/magick.wasm').href;
    await initializeImageMagick(wasmLocation);
})();

Thanks!

Steps to Reproduce

Example in bug description.

Images

magick-wasm bad import

@dlemstra
Copy link
Owner

That functionality has not yet been released. This will become available in the next release. If you really need this I can publish a new release sooner?

@theomarkkuspaul
Copy link
Author

No rush, thanks for the update!

@dlemstra dlemstra added this to the 0.0.22 milestone May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants