Socket
Socket
Sign inDemoInstall

probe-image-size

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

probe-image-size

Get image size without full download (JPG, GIF, PNG, WebP, BMP, TIFF, PSD)


Version published
Weekly downloads
500K
decreased by-13.31%
Maintainers
1
Weekly downloads
 
Created

What is probe-image-size?

The probe-image-size npm package is used to quickly and efficiently determine the dimensions and type of an image by reading only a small portion of the file. This can be particularly useful for applications that need to handle images but want to avoid loading entire files into memory.

What are probe-image-size's main functionalities?

Get Image Dimensions

This feature allows you to get the dimensions of an image by reading a stream of the image file. The code sample demonstrates how to use the probe-image-size package to read an image file from the filesystem and log its dimensions.

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

async function getImageDimensions(filePath) {
  const stream = fs.createReadStream(filePath);
  const result = await probe(stream);
  console.log(result);
}

getImageDimensions('path/to/image.jpg');

Get Image Type

This feature allows you to determine the type of an image (e.g., JPEG, PNG, GIF) by reading a stream of the image file. The code sample demonstrates how to use the probe-image-size package to read an image file from the filesystem and log its type.

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

async function getImageType(filePath) {
  const stream = fs.createReadStream(filePath);
  const result = await probe(stream);
  console.log(result.type);
}

getImageType('path/to/image.jpg');

Get Image Dimensions from URL

This feature allows you to get the dimensions of an image from a URL by fetching the image and reading its stream. The code sample demonstrates how to use the probe-image-size package to fetch an image from a URL and log its dimensions.

const probe = require('probe-image-size');
const fetch = require('node-fetch');

async function getImageDimensionsFromURL(url) {
  const response = await fetch(url);
  const result = await probe(response.body);
  console.log(result);
}

getImageDimensionsFromURL('https://example.com/image.jpg');

Other packages similar to probe-image-size

Keywords

FAQs

Package last updated on 27 Jan 2022

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