-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Usage in Browser #4
Comments
The current v0.0.1 NPM package is only usable within a Node.js environment (for now). I still have to figure out how to distribute the web variant or check whether it is possible to use an multi-targeted output (one that can be used on both web and Node), as I don't want to blow the NPM package up too much (in terms of size). As a potential workaround you could just download these files from the playground. Or build it yourself in the source directory with |
There does not seem be be any "scripts": {
"build": "docker build -t wasm-vips . && docker run --rm -v $(pwd):/src wasm-vips ./build.sh",
"test:web": "serve -c test/unit/serve.json",
"test:node": "cd test/unit && npm run test",
"test": "npm run test:node",
"bench:web": "serve -c test/bench/serve.json",
"bench:node": "cd test/bench && npm run test",
"bench": "npm run bench:node"
}, |
The next version of wasm-vips will include the web variant in the NPM package using the following structure: $ tree lib/ -h --dirsfirst
lib/
├── node-commonjs
│ ├── [ 94K] vips.js
│ └── [ 3.1K] vips.worker.js
├── node-es6
│ ├── [ 94K] vips.mjs
│ └── [ 3.2K] vips.worker.mjs
├── [ 248K] vips.d.ts
├── [ 93K] vips-es6.js
├── [ 2.3K] vips-es6.worker.js
├── [ 93K] vips.js
├── [ 4.8M] vips.wasm
└── [ 2.4K] vips.worker.js
2 directories, 10 files The @amittal-quot The |
@kleisauke Thanks for your great work!
I'm not familiar with Emscripten cross compile, could you help me figure out this ? #6 |
@JoxC It looks like this Meson patch was not applied during the build of the Docker image. Lines 23 to 25 in 71ee394
Please can you open a new issue for this. |
Ok, seems to be working now, rather than using I believe the parcel bundler was bundling incorrectly when it was |
Is SVG loading supported? newFromBuffer throws |
@blipk I'm glad it's working now. The README reflects the upcoming v0.0.2 release, which should arrive when libvips 8.12 is released. ES6 module import doesn't currently work on the web, as you noticed. I had to revert that with commit ba6f7ee to ensure compatibility with Firefox. The difference between wasm-vips and the pre-built binaries provided by sharp (and NetVips) is that these dependencies are not (currently) compiled for WebAssembly:
1: Also requires: gdk-pixbuf, cairo, pixman, fontconfig, pango, freetype, harfbuzz, fribidi and libxml2. |
Thanks, I was confused as calling svgload was saying it doesnt exist if called with correct args, but if given extra args would give me an argument count error. The pre-emptive docs are a little confusing too. I managed to use a canvas to convert SVG to png data URI, then fetch that to a blob, and then convert that to a uint8array to pass to newFromBuffer |
v0.0.2 now available. |
I've installed this npm package in a repo using storybook, as I'm trying to experiment with it in React but I'm unable to get it working in the browser. Of course, it downloads a version of the package for node use only, so I'm wondering how to get this working in a browser, since the files provided by the npm package use things specific to node.
I know the playground works, so do I have to grab a copy of this repo and build things locally?
The text was updated successfully, but these errors were encountered: