Skip to content
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

Using Image #455

Open
pgamerx opened this issue Jan 3, 2021 · 1 comment
Open

Using Image #455

pgamerx opened this issue Jan 3, 2021 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@pgamerx
Copy link

pgamerx commented Jan 3, 2021

Hey there!
I am using your package for Discord bot using discord.js
I do the following thing

  msg.attachments.forEach(async(Attachment) => {
      
    let lol = await canvas.loadImage(Attachment.url)
    })

But I get error -

(node:7766) UnhandledPromiseRejectionWarning: Error: pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was Image

what can I do else except loading image??

@GantMan GantMan added enhancement New feature or request question Further information is requested labels Jan 4, 2021
@GantMan
Copy link
Member

GantMan commented Jan 4, 2021

If you're looking to load from a URL, you have to first load the image into an image object.

Take a look at: https://github.com/infinitered/nsfwjs/blob/master/example/minimal_demo/index.html

However, I'm considering adjusting the code so that if a string is provided, perhaps I can do this for you automatically?

Which do you prefer? Would you want to pass an image, or do you want me to automatically handle URLs and access images for you? The problem with the second option, is that it might need to be specific to URLs vs local URIs like file://

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants