wasm-vips file does not exist
Ok this is not directly a deno thing, but anyway. Has anyone successfully used wasm-vips with
vips.Image.newFromFile(path);
?
For me vips.Image.newFromBuffer(buffer)
works well. But opening local files directly for example vips.Image.newFromFile('sample.jpg')
always complains:
I thought it would be an issue of relative paths, but I tried all kinds of relative paths (relative to Deno.cwd(), or import.meta.url, or the directory where vips-es6.js is stored), with no luck.
Furthermore I tried a simple filename without path, and put a sample.jpg in every directory I could think of where it might try to load it. No luck.
Am I missing something, or is this is a bug with wasm-vips on deno?2 Replies
(for reference, this is the repo: https://github.com/kleisauke/wasm-vips/ and otherwise it seems to work awesomely well, except .AVIF is superslow atm, like 100x slower than other formats like JPG, WebP and even JPEG XL)
Well, I went ahead and created an issue, let's see https://github.com/kleisauke/wasm-vips/issues/59
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, there are a few things you might want to consider:
1. Ensure that the file
sample.jpg
actually exists in the path you are specifying and that the Deno process has the necessary permissions to read from that file location. Deno is secure by default, so you need to explicitly grant file system access using the --allow-read
flag.
2. If you are running your Deno script from a different directory, remember that the path you provide to vips.Image.newFromFile
should be either absolute or relative to the current working directory of the Deno process (Deno.cwd()
).
3. Since you mentioned that vips.Image.newFromBuffer(buffer)
works well, as a workaround, you could read the file into a buffer using Deno's standard library and then use that buffer with newFromBuffer
. Here's an example of how you might do that:
Remember to use the --allow-read
flag when running your script to grant file read permission.
Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. If the issue persists, it might be worth checking the wasm-vips documentation or reaching out to the wasm-vips community for more specific guidance.