# image-downloader

> A Nodejs module for downloading image to disk from a given URL

Latest version **4.3.1** (published 2026-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install image-downloader
pnpm add image-downloader
yarn add image-downloader
bun add image-downloader
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 4.3.1 |
| Published | 2026-10-02 |
| First published | 2016-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6.10.1 |
| Dependencies | 1 |
| Unpacked size | 19.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sébastien Demanou |
| Maintainers | demsking |
| Keywords | image, download, downloader, images |

## Links

- npm: https://www.npmjs.com/package/image-downloader
- Repository: https://gitlab.com/demsking/image-downloader
- Issues: https://gitlab.com/demsking/image-downloader/issues
- npm.io page: https://npm.io/package/image-downloader

## Dependencies (1)

- [follow-redirects](https://npm.io/package/follow-redirects.md) ^1.15.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 4.3.1 (latest) — 2026-10-02
- 4.3.0 — 2022-05-04
- 4.2.0 — 2022-04-11
- 4.1.0 — 2022-02-25
- 4.0.3 — 2021-07-13
- 4.0.2 — 2020-12-11
- 4.0.1 — 2020-05-10
- 3.6.0 — 2020-05-10
- 4.0.0 — 2020-05-10
- 3.5.0 — 2019-07-29
- 3.4.2 — 2018-12-08
- 3.4.1 — 2018-06-09
- 3.4.0 — 2018-05-31
- 3.3.0 — 2017-09-20
- 3.2.2 — 2017-06-02
- … 7 more at https://npm.io/package/image-downloader/versions

## README

# Node Image Downloader

A Node module for downloading image to disk from a given URL

[![npm](https://img.shields.io/npm/v/image-downloader.svg)](https://www.npmjs.com/package/image-downloader)
[![Build status](https://gitlab.com/demsking/image-downloader/badges/main/pipeline.svg)](https://gitlab.com/demsking/image-downloader/pipelines)
[![Test coverage](https://gitlab.com/demsking/image-downloader/badges/main/coverage.svg)](https://gitlab.com/demsking/image-downloader/pipelines)
[![Buy me a beer](https://img.shields.io/badge/Buy%20me-a%20beer-1f425f.svg)](https://www.buymeacoffee.com/demsking)

## Install

```sh
npm install --save image-downloader
```

## Options

- **url** (*required*) - the image URL to download
- **dest** (*required*) - the image destination. Can be a directory or a
  filename. If a directory is given, ID will automatically extract the image
  filename from `options.url` (see usage bellow)
- **extractFilename** - boolean indicating whether the image filename will be
  automatically extracted from `options.url` or not. Set to `false` to have
  `options.dest` without a file extension for example. (default: `true`)
- **headers** - HTTP headers (default: `{}`)
- **timeout** - milliseconds before a request times out
- **maxRedirects** - the maximum number of allowed redirects; if exceeded, an
  error will be emitted. (default: `21`)

For advanced options, see [Node.js `http.request()`'s options documentation](https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback)

## Usage

Download to a directory and save with the original filename

```js
const download = require('image-downloader');

const options = {
  url: 'http://someurl.com/image.jpg',
  dest: '/path/to/dest',               // will be saved to /path/to/dest/image.jpg
};

download.image(options)
  .then(({ filename }) => {
    console.log('Saved to', filename); // saved to /path/to/dest/image.jpg
  })
  .catch((err) => console.error(err));
```

Download to a directory and save with an another filename

```js
const download = require('image-downloader');

options = {
  url: 'http://someurl.com/image2.jpg',
  dest: '/path/to/dest/photo.jpg',     // will be saved to /path/to/dest/photo.jpg
};

download.image(options)
  .then(({ filename }) => {
    console.log('Saved to', filename); // saved to /path/to/dest/photo.jpg
  })
  .catch((err) => console.error(err));
```

Download with another filename without extension

```js
const download = require('image-downloader');

options = {
  url: 'http://someurl.com/image3.jpg',
  dest: '/path/to/dest/photo',         // will be saved to /path/to/dest/photo
  extractFilename: false,
};

download.image(options)
  .then(({ filename }) => {
    console.log('Saved to', filename), // saved to /path/to/dest/photo
  })
  .catch((err) => console.error(err));
```

## Development Setup

1. [Install Nix Package Manager](https://nixos.org/manual/nix/stable/installation/installing-binary.html)

2. [Install `direnv` with your OS package manager](https://direnv.net/docs/installation.html#from-system-packages)

3. [Hook it `direnv` into your shell](https://direnv.net/docs/hook.html)

4. At the top-level of your project run:

   ```sh
   direnv allow
   ```

   > The next time your launch your terminal and enter the top-level of your
   > project, `direnv` will check for changes.

## Contribute

Please follow [CONTRIBUTING.md](https://gitlab.com/demsking/image-downloader/blob/main/CONTRIBUTING.md).

## Changelog

See [CHANGELOG.md](https://gitlab.com/demsking/image-downloader/blob/main/CHANGELOG.md)
for the notable changes of each release.

## License

Under the MIT license. See [LICENSE](https://gitlab.com/demsking/image-downloader/blob/main/LICENSE) file for more details.

---
_Source: https://npm.io/package/image-downloader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
