Socket
Socket
Sign inDemoInstall

image-size

Package Overview
Dependencies
0
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    image-size

get dimensions of any image file


Version published
Maintainers
1
Install size
6.44 kB
Created

Package description

What is image-size?

The image-size npm package is a module that provides a simple API to determine the dimensions of an image file. It supports a variety of image formats, including but not limited to JPEG, PNG, GIF, BMP, and WebP. The package can be used in both synchronous and asynchronous contexts and can handle local files as well as remote images via URLs.

What are image-size's main functionalities?

Synchronous image size retrieval

This feature allows you to synchronously get the dimensions of an image by providing the path to the image file.

const sizeOf = require('image-size');
const dimensions = sizeOf('path/to/image.jpg');
console.log(dimensions.width, dimensions.height);

Asynchronous image size retrieval

This feature allows you to asynchronously get the dimensions of an image by providing the path to the image file and a callback function.

const sizeOf = require('image-size');
sizeOf('path/to/image.jpg', (err, dimensions) => {
  if (err) throw err;
  console.log(dimensions.width, dimensions.height);
});

Image size retrieval from a buffer

This feature allows you to get the dimensions of an image from a buffer, which is useful when you have the image data in memory rather than stored in a file.

const sizeOf = require('image-size');
const fs = require('fs');

fs.readFile('path/to/image.jpg', (err, data) => {
  if (err) throw err;
  const dimensions = sizeOf(data);
  console.log(dimensions.width, dimensions.height);
});

Other packages similar to image-size

Readme

Source

NPM version Build Status

Instalation

npm install image-size

Usage
var sizeOf = require('image-size');
var dimesions = sizeOf('images/funny-cats.png');
console.log(dimesions.width, dimesions.height);
Supported formats
  • BMP
  • GIF
  • JPEG
  • PNG
  • PSD
Upcoming
  • TIFF
  • WebP
Credits

not a direct port, but an attempt to have something like dabble's imagesize as a node module.

Keywords

FAQs

Last updated on 03 Jul 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc