image-info

Get Image Info

Usage no npm install needed!

<script type="module">
  import imageInfo from 'https://cdn.skypack.dev/image-info';
</script>

README

image-info

Supported formats

  • BMP
  • GIF
  • JPEG
  • PNG
  • PSD
  • TIFF
  • WebP
  • SVG

Usage

npm install image-info --save

Example

const imageInfo = require('image-info');

imageInfo('./test/images/jpg.jpg', (err, info) => {
    if (err) return console.warn(err);
    console.log(info);
});

Callback will return err, info, and info would be return like:

{
  sha1: 'b9ccbb8e5c818bb517352222fd69c8c43e9755b5',
  bytes: 36357,
  ext: 'jpg',
  mime: 'image/jpeg',
  height: 420,
  width: 560,
  type: 'jpg'
}

Animated WebP

{
  "sha1": "5432293fb2f048be5121683ff721a081bf6e13b1",
  "bytes": 663854,
  "ext": "webp",
  "mime": "image/webp",
  "width": 480,
  "height": 480,
  "webp": {
    "featuresPresent": "animation",
    "bgColor": "0xFFFFFFFF",
    "loopCount": 0,
    "frames": [
      {
        "No": 1,
        "width": 480,
        "height": 480,
        "alpha": "no",
        "x_offset": 0,
        "y_offset": 0,
        "duration": 150,
        "dispose": "none",
        "blend": "yes",
        "image_size": 168478
      },
      { ... },
      { ... },
      { ... }
    ],
    "duration": 150
  }
}

Update Log

0.0.2

  • fix: animated webp image cannot read attributes