https://github.com/techroot777/image-batch-download
A simple package for single or batch image download and conversion using node streams.
https://github.com/techroot777/image-batch-download
batch download download-manager downloader image image-processing png typescript webp
Last synced: about 1 year ago
JSON representation
A simple package for single or batch image download and conversion using node streams.
- Host: GitHub
- URL: https://github.com/techroot777/image-batch-download
- Owner: techroot777
- License: mit
- Created: 2021-12-26T04:19:39.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-23T22:48:30.000Z (over 4 years ago)
- Last Synced: 2024-08-08T22:33:51.493Z (almost 2 years ago)
- Topics: batch, download, download-manager, downloader, image, image-processing, png, typescript, webp
- Language: TypeScript
- Homepage:
- Size: 19.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# image-batch-download
[](https://badge.fury.io/js/image-batch-downloader)
A simple package for basic image downloading and processing.
Supported formats:
- JPEG
- PNG
- WebP
## Installation
With Yarn:
```bash
yarn add image-batch-downloader
```
Or with NPM:
```bash
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.
```ts
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.
```ts
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