Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

image-size

Package Overview
Dependencies
Maintainers
3
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-size

get dimensions of any image file

  • 0.7.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created

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

Keywords

FAQs

Package last updated on 08 Jan 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc