-
Notifications
You must be signed in to change notification settings - Fork 146
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
photon usage on WebWorker #46
Comments
Hi @YukSeungChan Thanks for submitting this issue! I've had a look at your code, and it appears that the issue is related to the manner in which you're fetching your image, since the result is encoded as a string rather than as a buffer. I've coded a small example to help out. This issue has also cropped up for someone else, so I'll update the docs to include an example also.
Hope this helps 😄 If you have any other questions, let me know! |
Thanks for the answer. I can't use node-fetch. How can I encode the ArrayBuffer of Web API to base64 in the browser? The code I wrote above doesn't work. |
I am not able to use this library in web workers 😥 Can you please show us a full example on how to achieve this. ( I am fairly new to wasm ) So far my index.html contains :
My photon-worker.js file contains :
Thanks 👍 |
For converting buffer to dataUrl (b64), you can check: |
I tried creating a minimal project expressing the problem: |
Here is an example of using Photon Image Library on Cloudflare Workers: |
Great Works! Can you publish as an npm package? |
Thanks, I deploy success Support png: https://image.miantiao.me/?url=https%3A%2F%2Fstatic.miantiao.me%2Fbanner-big.jpeg&action=resize!820,400,1&format=png Support jpg: https://image.miantiao.me/?url=https%3A%2F%2Fstatic.miantiao.me%2Fbanner-big.jpeg&action=resize!820,400,1&format=jpg Support webp: https://image.miantiao.me/?url=https%3A%2F%2Fstatic.miantiao.me%2Fbanner-big.jpeg&action=resize!820,400,1&format=webp |
Glad to hear 😃 |
I
I published a npm package for cloudflare workers: https://www.npmjs.com/package/@cf-wasm/photon |
Can you share the source code if you don't mind? |
Let me sort it out this weekend |
@suragch @techwithdeo Look Here https://github.com/ccbikai/cloudflare-worker-image |
Thank you :) |
Not working here :( I'm using Cloudflare Pages. |
I recently updated @cf-wasm/photon, and now it supports Cloudflare Workers, Cloudflare Pages, Next.js and node environment. Use @cf-wasm/photon for Next.js (Webpack) as shown: import * as photon from "@cf-wasm/photon/next"; |
Oh you should definetly add this as a feature to the README, do open a PR! |
hi @techwithdeo @ccbikai , |
Web Workers (using Webpack bundler): Cloudflare Workers: Next.js (App router + Edge Runtime): Next.js (Pages router + Edge Runtime): |
Hello,
I want to use this library on Cloudflare workers. Cloudflare workers run on WebWorker environment.
I imported photon-rs on rust project and build with wasm-pack.
I get "RuntimeError: unreachable" error on some images converted into base64.
In docs, I saw an example utilizing canvas but are there other ways to store it on memory?
[Code]
[Error]
The text was updated successfully, but these errors were encountered: