banananas
banananas4mo ago

Getting the width and height of an image

I'm trying to get the width and height of an image but I'm not sure how to do so. Could anyone tell me how?
3 Replies
m4rc3l05
m4rc3l054mo ago
From a simple jsr search i got this package https://jsr.io/@retraigo/image-size
import { getImageInfo } from "jsr:@retraigo/image-size";

const imgData = getImageInfo(Deno.readFileSync("./image.png"));
console.log("x", imgData);
import { getImageInfo } from "jsr:@retraigo/image-size";

const imgData = getImageInfo(Deno.readFileSync("./image.png"));
console.log("x", imgData);
deno run -A --no-lock foo.ts
x { width: 200, height: 300, format: "png", shape: [Function: shape] }
deno run -A --no-lock foo.ts
x { width: 200, height: 300, format: "png", shape: [Function: shape] }
Do not know if we have a native way of doing this on deno...
iuioiua
iuioiua4mo ago
Note: this has nothing to do with the Standard Library
banananas
banananasOP4mo ago
Alr, i'll try that yep, that works! thanks for the help

Did you find this page helpful?