How to import the Image class to Deno Fresh?
I'm trying to access an image's
naturalHeight
and naturalWidth
. But when I construct the object new Image()
I get a Reference Error that it is not defined. I figured I could import it from a preact module or something similar to (import {Image} from 'preact/image
), but I simply couldn't find out from which module to import it.2 Replies
Image
is a class that exists in the browser but not in Deno
the browser obviously knows how to parse and render images, because it has to, but Deno doesn't
I don't think there's a polyfill that you could import
but depending on the image formats you need, there might be libraries that might do that with a different APIThank you for your answer. I understand your point, I was trying to do this inside of an Island with the hopes that the Image would be constructed on the client. As you pointed out, the module imagescript is exactly what I was looking for.