lumeland / imagemagick-deno

Deno port of the WASM library for ImageMagick
https://deno.land/x/imagemagick_deno
Apache License 2.0
44 stars 3 forks source link

'TypeError: Invalid URL: 'magick.wasm'' error when running #15

Closed lowercasename closed 3 months ago

lowercasename commented 3 months ago

Here's the minimal function which errors:

export const test = async () => {
    await initializeImageMagick();
    console.log(Magick.imageMagickVersion);
};

I'm running the initialize function inside another function because if I try running await initializeImageMagick(); at the top level, I get this other error:

error: Top-level await promise never resolved
await initializeImageMagick();

Here's the stack trace:

error: Uncaught (in promise) TypeError: Invalid URL: 'magick.wasm'
    at getSerialization (ext:deno_url/00_url.js:98:11)
    at new URL (ext:deno_url/00_url.js:405:27)
    at new Request (ext:deno_fetch/23_request.js:329:25)
    at ext:deno_fetch/26_fetch.js:319:27
    at new Promise (<anonymous>)
    at fetch (ext:deno_fetch/26_fetch.js:315:18)
    at instantiateAsync (https://deno.land/x/imagemagick_deno@0.0.26/src/wasm/magick_native.js:8:7353)
    at createWasm (https://deno.land/x/imagemagick_deno@0.0.26/src/wasm/magick_native.js:8:8361)
    at https://deno.land/x/imagemagick_deno@0.0.26/src/wasm/magick_native.js:8:146546
    at https://deno.land/x/imagemagick_deno@0.0.26/src/image-magick.ts:57:9
Watcher Process failed. Restarting on file change...

The same error happens if I try and perform an actual operation with ImageMagick.

deno 1.45.2 (release, aarch64-apple-darwin)
v8 12.7.224.12
typescript 5.5.2

Let me know if you need anything else!

oscarotero commented 3 months ago

The correct function to import is initialize:

import { initialize } from "imagemagick_deno";

await initialize();
lowercasename commented 3 months ago

Thank you, I have no idea how I made this mistake!