nsfwjs
nsfwjs copied to clipboard
Using Image
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??
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://