image-batch-downloader
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

image-batch-download

npm version

A simple package for basic image downloading and processing.

Supported formats:

  • JPEG
  • PNG
  • WebP

Installation

With Yarn:

yarn add image-batch-downloader

Or with NPM:

npm install image-batch-downloader

How to use

Single download

The code below will download the 150 pixel image, convert it to WebP at 75% of the original quality, and resize it to 100 size.

const downloader = getDownloader();
const imageSettings: ImageSettings = {
    imageUrl: 'https://via.placeholder.com/150',
    toFormat: ImageFormat.Webp,
    quality: 75,
    outputPath: './output/my-output-image.webp',
    size: 100
};
await downloader.download(imageSettings);

Batch download

const downloader = getDownloader();
const urls = [
  'https://path-to-image-1.jpeg',
  'https://path-to-image-2.png',
  'https://path-to-image-3.webp'
];
const format = ImageFormat.Png;
const settings: ImageSettings[] = urls.map((url, index) => ({
    imageUrl: url,
    toFormat: format,
    quality: 75,
    outputPath: `./output/image-${index}.${format}`,
    size: 100
}));
await downloader.batchDownload(settings, 25);

When to use?

  • For web scraping of image-rich sites
  • To download hundreds or thousands of remote images without the server identifying the numerous requests as an attack
  • To process many images asynchronously and consuming minimal resources

Why this package?

  • Use of streams
  • Asynchronous code usage
  • Simple and easy to use API

Package Sidebar

Install

npm i image-batch-downloader

Weekly Downloads

1

Version

2.0.1

License

MIT

Unpacked Size

62 kB

Total Files

21

Last publish

Collaborators

  • gseis
  • techroot777