A simple package for single or batch image download and conversion using node streams.

Overview

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

Scenario similar to the previous one but with PNG format and limit of 10 simultaneous downloads.

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
}));
downloader.batchDownload(settings, 10).subscrible();

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
  • Use of observables to emit the progress of batch downloads
  • Asynchronous code usage
  • Simple and easy to use API
You might also like...

Nodejs Background jobs using redis.

Nodejs Background jobs using redis.

node-resque: The best background jobs in node. Distributed delayed jobs in nodejs. Resque is a background job system backed by Redis (version 2.6.0 an

Jan 3, 2023

Send emails using Cloudflare Worker, for free.

Email API for Proselog. Not intended for use outside of Proselog, but it should work with any worker, without any configuration. import { sendEmail }

Nov 7, 2022

Using Cloudflare worker to generate host list from firebog to keep updated.

AdGuardCloudflareHostGenerator Use a cloudflare worker to generate a up to date list from FireBog's ticked list found at https://v.firebog.net/hosts/l

Nov 30, 2022

Type-safe and Promisified API for Web Worker and Iframe

💛 You can help the author become a full-time open-source maintainer by sponsoring him on GitHub. typed-worker Install npm i typed-worker Usage Create

Dec 31, 2022

Redis-backed task queue engine with advanced task control and eventual consistency

idoit Redis-backed task queue engine with advanced task control and eventual consistency. Task grouping, chaining, iterators for huge ranges. Postpone

Dec 15, 2022

Build and deploy a roadmap voting app for your porject

Build and deploy a roadmap voting app for your porject

Roadmap Voting App You can deploy Roadmap application yourself and get feedback from your users about your roadmap features. See the live example. In

Jan 3, 2023

Making service workers easy so that your app is fast and reliable, even offline.

tulo.js Making service workers easy to use so that your app can be fast and reliable, even offline. Welcome to tulo.js, a service worker library that

Nov 16, 2022

Example repo for getting NextJS, Rust via wasm-pack, and web workers all playing nicely together.

Example of integrating WASM & web workers with a Typescript NextJS project. Running yarn yarn dev Open localhost:3000 Layout Rust code is in ./rust, g

Dec 23, 2022

generate statistics on the number of audience minutes your site is generating, and if readers make it to the end of your screeds

generate statistics on the number of audience minutes your site is generating, and if readers make it to the end of your screeds

audience-minutes generate statistics on the number of audience minutes your site is receiving, and if readers make it to the end of your screeds. “If

Dec 28, 2022
Comments
  • FIX: Err unescaped characters

    FIX: Err unescaped characters

    Problem: When downloading some images with special characters in the URL, "TypeError [ERR_UNESCAPED_CHARACTERS] Request path contains unescaped characters" error occurred.

    Solution: Use node's URL lib to encode the url.

    bug 
    opened by duraes-antonio 0
Releases(v2.0.0)
  • v2.0.0(Jan 1, 2022)

    What's Changed

    • Limit concurrent requests by @duraes-antonio in https://github.com/techroot777/image-batch-download/pull/2

    Full Changelog: https://github.com/techroot777/image-batch-download/compare/v1.0.3...v2.0.0

    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Jan 1, 2022)

    What's Changed

    • FIX: Err unescaped characters by @duraes-antonio in https://github.com/techroot777/image-batch-download/pull/1

    New Contributors

    • @duraes-antonio made their first contribution in https://github.com/techroot777/image-batch-download/pull/1

    Full Changelog: https://github.com/techroot777/image-batch-download/compare/v1.0.0...v1.0.3

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Dec 26, 2021)

    • JS doc on methods
    • Embedded typing for TS
    • Single and batch download support
    • Delay support for batch download
    • Supported formats: jpeg, png, webp
    Source code(tar.gz)
    Source code(zip)
Owner
Tech Root 777
Tech Root 777
Premium Queue package for handling distributed jobs and messages in NodeJS.

The fastest, most reliable, Redis-based queue for Node. Carefully written for rock solid stability and atomicity. Sponsors · Features · UIs · Install

null 13.5k Dec 31, 2022
A simple Node.js APIBAN client for downloading banned IPs and inserting them into a redis set

apiban-redis A simple Node.js APIBAN client for downloading banned IPs and inserting them into a redis set. Installation This utility can be run as a

jambonz 4 Apr 5, 2022
A simple, fast, robust job/task queue for Node.js, backed by Redis.

A simple, fast, robust job/task queue for Node.js, backed by Redis. Simple: ~1000 LOC, and minimal dependencies. Fast: maximizes throughput by minimiz

Bee Queue 3.1k Jan 5, 2023
A simple high-performance Redis message queue for Node.js.

RedisSMQ - Yet another simple Redis message queue A simple high-performance Redis message queue for Node.js. For more details about RedisSMQ design se

null 501 Dec 30, 2022
Job queues and scheduled jobs for Node.js, Beanstalkd and/or Iron.io.

Ironium Job queues and scheduled jobs for Node.js backed by Beanstalk/IronMQ/SQS. The Why You've got a workload that runs outside the Web app's reques

Assaf Arkin 71 Dec 14, 2022
Bree is the best job scheduler for Node.js and JavaScript with cron, dates, ms, later, and human-friendly support.

The best job scheduler for Node.js and JavaScript with cron, dates, ms, later, and human-friendly support. Works in Node v10+ and browsers, uses workers to spawn sandboxed processes, and supports async/await, retries, throttling, concurrency, and graceful shutdown. Simple, fast, and lightweight. Made for @ForwardEmail and @ladjs.

Bree - The Best Node.js and JavaScript Job Scheduler 2.5k Dec 30, 2022
A fast, robust and extensible distributed task/job queue for Node.js, powered by Redis.

Conveyor MQ A fast, robust and extensible distributed task/job queue for Node.js, powered by Redis. Introduction Conveyor MQ is a general purpose, dis

Conveyor MQ 45 Dec 15, 2022
Kue is a priority job queue backed by redis, built for node.js.

Kue Kue is no longer maintained Please see e.g. Bull as an alternative. Thank you! Kue is a priority job queue backed by redis, built for node.js. PRO

Automattic 9.4k Dec 20, 2022
Lib for work to multiple thread (Node.js)

ad-worker npm i ad-worker This library allows spawn threads and transfer control by name, with an isolated context, or shared data between threads. Ex

Артём Полторацкий 10 Nov 6, 2022
Redis Simple Message Queue

Redis Simple Message Queue A lightweight message queue for Node.js that requires no dedicated queue server. Just a Redis server. tl;dr: If you run a R

Patrick Liess 1.6k Dec 27, 2022