imagejs icon indicating copy to clipboard operation
imagejs copied to clipboard

How to get metadata of images?

Open jingsam opened this issue 8 years ago • 1 comments

Hi, I want to resize my images to half size, but I do not know the size of orignal image. How can I get this?

jingsam avatar Apr 29 '16 08:04 jingsam

Hi, I want to resize my images to half size, but I do not know the size of orignal image. How can I get this?

Hi, if someone is looking for metadata especially size of image you have 2 option :

  1. You can print bitmap after initialization , and log bitmap details.

`var bitmap = new Bitmap();

  bitmap.readFile(`sourceimg.png`).then(function () {
    // bitmap is ready
    console.log("bitmapData >>>", bitmap);

` Here you get bitmap detail :

ready { _data: { data: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 974 more bytes>, width: 16, height: 16 } }

2.Also you can use another module https://www.npmjs.com/package/image-size

cristea2017 avatar Jul 15 '20 10:07 cristea2017