-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support ImageBitmap
and createImageBitmap
#876
Comments
Does this include to define it as a context? |
That would need to be done on the end of jsdom (or whatever DOM library), but yes, the request is for allowing node-canvas to be used by such libraries for such purposes. |
NodeJS just introduced a import { openAsBlob } from 'node:fs'
const blob = await openAsBlob('the.file.png')
const bitmap = await createImageBitmap(blob) you may also fetch blobs natively const blob = await response.blob() |
I want to make https://github.com/imgly/background-removal-js support both web and node platform, and I found this canvas for node project but it seems missing some api like See also: |
If you would like to support some basic version of import { openAsBlob } from 'node:fs'
import { Image } from 'canvas'
async function createImageBitmap (blob) {
const ab = await blob.arrayBuffer()
const img = new Image()
await new Promise(rs => {
img.onload = rs
img.src = new Uint8Array(ab) // might have to do: Buffer.from(ab)
})
return img
}
const blob = await fetch(request).then(res => res.blob())
const blob = await openAsBlob('the.file.png')
const bitmap = await createImageBitmap(blob) imo i think that the |
@jimmywarting the code sample above refers to undefined methods, like |
Feature
Add and expose
ImageBitmap
andcreateImageBitmap
and allow their use within relevant canvas methods (ideally also working withjsdom
to hook into this as well).The text was updated successfully, but these errors were encountered: