4.3.0 • Published 3 years ago

image-downloader v4.3.0

Weekly downloads
7,625
License
MIT
Repository
gitlab
Last release
3 years ago

Node Image Downloader

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

npm Build status Test coverage Buy me a beer

Install

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

Usage

Download to a directory and save with the original filename

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

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

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

  2. Install direnv with your OS package manager

  3. Hook it direnv into your shell

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

    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.

License

Under the MIT license. See LICENSE file for more details.

images-for-minsmartboxes-sticker-printergoogleslides-makercloudinary_image_generator@fabapp/publicadorpinterest-exporterimages-for-meisoftstone-egg-frameworkpindown-clifbpaldl-clitamnt-imagewikiscrapingwillitsupabase-image-optimisersupabase-video-optimiservrt-runner-gitlab@dendronhq/pods-corejayfirejane-facebookkeytrovepriyanshbottruffle-tstraffic-camerastootcord@aueangpanit/ytd-cli@baby-cli/shared@bpw1621/imgscrapewarframe-nexus-querywarframe-wikia-scraperts-scraperurl-md-fs@felwine/sdk@gtpkg/imgdl@idigi/reaction-plugin-files@em-cli/shared@frontender-magazine/article-builder@frontender-magazine/builder@longlost/magic-bulk-data-tool@micmac/youtube@excelespina/ingredient-scraper@mikejhan4455/gatsby-theme-gine-blog-chris-edition@joktec/storage@kauffmaneli/altru-module@kevinazhu/hubot-rss-reader@notifiles/sdk@spriteful/magic-bulk-data-tool@solar.himalayas/spider@spantree/snapimy-hexo-doubanmonti-vendor-climirror_adminmyreadingmanga-unofficialoculowobooksrarapwa-image-generatornhentai-gdrive-uploadernomad-service-timernomad-service-timer-rebootpicsart-image-scrapeplaygroundaipianobar-notifierpress2bloggerpriyanshbot12ridiculously-awesome-wallpaperredbidreddit-dlrecipefinderresponsive-breakpoints-generatorsmaller-imagesghost-to-gatsbygrabvatarimgetimdb-movieimage-fetcherimage-receive-sqlserverinstagram-crawlerinstabotjsinstagram-public-apiliquiscraperlistal-botline-sticker-downloaderlight-scraperlocalpresslofter2hexolofter2jekyllmd-from-mediummemes-cli@szczepano/pitch2pdf@the-soliton/storage@therealraluvy/memeinstall@tf-img/image-predictiongatsby-source-behance-imagesgatsby-theme-gine-bloggatsby-theme-monkno-bloggatsby-theme-brainy-themegatsby-transformer-liist@tdi-mc/storagefacebox-google-photosfactbook
4.3.0

3 years ago

4.2.0

3 years ago

4.1.0

3 years ago

4.0.3

4 years ago

4.0.2

4 years ago

3.6.0

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.5.0

6 years ago

3.4.2

6 years ago

3.4.1

7 years ago

3.4.0

7 years ago

3.3.0

8 years ago

3.2.2

8 years ago

3.2.1

8 years ago

3.2.0

8 years ago

3.0.0

8 years ago

2.0.3

8 years ago

2.0.1

8 years ago

2.0.0

9 years ago

1.0.0

9 years ago