{"id":24922931,"url":"https://github.com/demsking/image-downloader","last_synced_at":"2025-04-09T19:15:58.520Z","repository":{"id":46104804,"uuid":"56752015","full_name":"demsking/image-downloader","owner":"demsking","description":"A Nodejs module for downloading image to disk from a given URL","archived":false,"fork":false,"pushed_at":"2022-08-28T03:04:52.000Z","size":522,"stargazers_count":69,"open_issues_count":1,"forks_count":15,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-09T19:15:50.199Z","etag":null,"topics":["download","downloader","image","nodejs"],"latest_commit_sha":null,"homepage":"https://gitlab.com/demsking/image-downloader","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/demsking.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-21T07:28:46.000Z","updated_at":"2024-11-21T22:57:35.000Z","dependencies_parsed_at":"2022-08-24T14:37:29.532Z","dependency_job_id":null,"html_url":"https://github.com/demsking/image-downloader","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demsking%2Fimage-downloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demsking%2Fimage-downloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demsking%2Fimage-downloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demsking%2Fimage-downloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/demsking","download_url":"https://codeload.github.com/demsking/image-downloader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094987,"owners_count":21046770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["download","downloader","image","nodejs"],"created_at":"2025-02-02T11:34:09.784Z","updated_at":"2025-04-09T19:15:58.477Z","avatar_url":"https://github.com/demsking.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/demsking"],"categories":[],"sub_categories":[],"readme":"# Node Image Downloader\n\nA Node module for downloading image to disk from a given URL\n\n[![npm](https://img.shields.io/npm/v/image-downloader.svg)](https://www.npmjs.com/package/image-downloader)\n[![Build status](https://gitlab.com/demsking/image-downloader/badges/main/pipeline.svg)](https://gitlab.com/demsking/image-downloader/pipelines)\n[![Test coverage](https://gitlab.com/demsking/image-downloader/badges/main/coverage.svg)](https://gitlab.com/demsking/image-downloader/pipelines)\n[![Buy me a beer](https://img.shields.io/badge/Buy%20me-a%20beer-1f425f.svg)](https://www.buymeacoffee.com/demsking)\n\n## Install\n\n```sh\nnpm install --save image-downloader\n```\n\n## Options\n\n- **url** (*required*) - the image URL to download\n- **dest** (*required*) - the image destination. Can be a directory or a\n  filename. If a directory is given, ID will automatically extract the image\n  filename from `options.url` (see usage bellow)\n- **extractFilename** - boolean indicating whether the image filename will be\n  automatically extracted from `options.url` or not. Set to `false` to have\n  `options.dest` without a file extension for example. (default: `true`)\n- **headers** - HTTP headers (default: `{}`)\n- **timeout** - milliseconds before a request times out\n- **maxRedirects** - the maximum number of allowed redirects; if exceeded, an\n  error will be emitted. (default: `21`)\n\nFor 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)\n\n## Usage\n\nDownload to a directory and save with the original filename\n\n```js\nconst download = require('image-downloader');\n\nconst options = {\n  url: 'http://someurl.com/image.jpg',\n  dest: '/path/to/dest',               // will be saved to /path/to/dest/image.jpg\n};\n\ndownload.image(options)\n  .then(({ filename }) =\u003e {\n    console.log('Saved to', filename); // saved to /path/to/dest/image.jpg\n  })\n  .catch((err) =\u003e console.error(err));\n```\n\nDownload to a directory and save with an another filename\n\n```js\nconst download = require('image-downloader');\n\noptions = {\n  url: 'http://someurl.com/image2.jpg',\n  dest: '/path/to/dest/photo.jpg',     // will be saved to /path/to/dest/photo.jpg\n};\n\ndownload.image(options)\n  .then(({ filename }) =\u003e {\n    console.log('Saved to', filename); // saved to /path/to/dest/photo.jpg\n  })\n  .catch((err) =\u003e console.error(err));\n```\n\nDownload with another filename without extension\n\n```js\nconst download = require('image-downloader');\n\noptions = {\n  url: 'http://someurl.com/image3.jpg',\n  dest: '/path/to/dest/photo',         // will be saved to /path/to/dest/photo\n  extractFilename: false,\n};\n\ndownload.image(options)\n  .then(({ filename }) =\u003e {\n    console.log('Saved to', filename), // saved to /path/to/dest/photo\n  })\n  .catch((err) =\u003e console.error(err));\n```\n\n## Development Setup\n\n1. [Install Nix Package Manager](https://nixos.org/manual/nix/stable/installation/installing-binary.html)\n\n2. [Install `direnv` with your OS package manager](https://direnv.net/docs/installation.html#from-system-packages)\n\n3. [Hook it `direnv` into your shell](https://direnv.net/docs/hook.html)\n\n4. At the top-level of your project run:\n\n   ```sh\n   direnv allow\n   ```\n\n   \u003e The next time your launch your terminal and enter the top-level of your\n   \u003e project, `direnv` will check for changes.\n\n## Contribute\n\nPlease follow [CONTRIBUTING.md](https://gitlab.com/demsking/image-downloader/blob/main/CONTRIBUTING.md).\n\n## License\n\nUnder the MIT license. See [LICENSE](https://gitlab.com/demsking/image-downloader/blob/main/LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemsking%2Fimage-downloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemsking%2Fimage-downloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemsking%2Fimage-downloader/lists"}