{"id":15601130,"url":"https://github.com/yinyanfr/image-down","last_synced_at":"2025-03-29T01:19:13.399Z","repository":{"id":165619015,"uuid":"641019922","full_name":"yinyanfr/image-down","owner":"yinyanfr","description":"Yet another library / CLI tool to batch compress / downscale images.","archived":false,"fork":false,"pushed_at":"2023-07-04T14:35:16.000Z","size":74,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-03T17:05:44.554Z","etag":null,"topics":["cli","image","image-compression","image-processing","image-resizer","reduce-size"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/image-down","language":"TypeScript","has_issues":true,"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/yinyanfr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-15T15:53:55.000Z","updated_at":"2023-07-07T20:32:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"77a8f67e-22a1-438c-b2d2-f83218764879","html_url":"https://github.com/yinyanfr/image-down","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"5777489536666396e4cb8c0210cca759d97082eb"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinyanfr%2Fimage-down","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinyanfr%2Fimage-down/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinyanfr%2Fimage-down/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yinyanfr%2Fimage-down/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yinyanfr","download_url":"https://codeload.github.com/yinyanfr/image-down/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246122392,"owners_count":20726823,"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":["cli","image","image-compression","image-processing","image-resizer","reduce-size"],"created_at":"2024-10-03T02:15:20.715Z","updated_at":"2025-03-29T01:19:13.379Z","avatar_url":"https://github.com/yinyanfr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# image-down\n\n[![npm](https://img.shields.io/npm/v/image-down.svg?style=flat-square)](https://www.npmjs.com/package/image-down)\n![license](https://img.shields.io/npm/l/image-down.svg?style=flat-square)\n![size](https://img.shields.io/github/repo-size/yinyanfr/image-down?style=flat-square)\n[![GitHub release](https://img.shields.io/github/release/yinyanfr/image-down.svg?style=flat-square)](https://github.com/yinyanfr/image-down/releases/latest)\n\nYet another CLI tool to batch compress / downscale images.\n\n## :green_book: Quick Start\n\n```bash\nnpx image-down images/* --width 800 --output compressed\n```\n\n```typescript\nimport { compressImages } from 'image-down';\n\n// For the wildcard example, please refer to the complete example below\nawait compressImages(['./images/image1.jpg'], {\n  width: 800,\n  outputDir: 'compressed',\n});\n```\n\n## :wrench: Cli\n\n```bash\nUsage: npx image-down [options]\n\nCommands:\n  help     Display help\n  version  Display version\n\nOptions:\n  -f, --format      Convert images to a format.\n  -h, --height      Resize images to a certain height.\n  -H, --help        Output usage information\n  -o, --output      Specify the output directory, default to '.'.\n  -p, --percentage  Resize images according to the width by percentage.\n  -s, --suffix      Adding a suffix to the output filename.\n  -v, --version     Output the version number\n  -w, --width       Resize images to a certain width.\n\nExamples:\n  - Compressing all files from folder images to jpg with widths of 800px and add '-min' to converted filenames, saving all compressed images to folder compressed.\n  $ npx image-down images/* --width 800 --format jpg --suffix min --output compressed\n```\n\n## :book: Library\n\n```typescript\nawait compressImages(pathsArray, options);\n```\n\n### Options\n\n| Name                 | Type     | Description                                                    |\n| -------------------- | -------- | -------------------------------------------------------------- |\n| percentage           | number   | Resize images according to the width by percentage.            |\n| width                | number   | Resize images to a certain width.                              |\n| height               | number   | Resize images to a certain height.                             |\n| format               | number   | Convert images to a format.                                    |\n| outputDir            | string   | Specify the output directory, will not output if not defined.  |\n| outputFilenameSuffix | string   | Adding a suffix to the output filename.                        |\n| returnBuffers        | boolean  | Returning all converted buffers with corresponding file paths. |\n| onProgress           | Function | A function that is called when each file is processed.         |\n\n#### onProgress\n\n| Name                | Type   | Description                    |\n| ------------------- | ------ | ------------------------------ |\n| filePath            | string | The original path to the file. |\n| fileBuffer          | Buffer | The converted file buffer.     |\n| progress            | Object | The progress object.           |\n| progress.queueIndex | number | File index.                    |\n| progress.total      | number | Queue length.                  |\n| progress.status     | string | \"success\" or \"failed\".         |\n| progress.filename   | string | The name of the output file.   |\n\n### Complete Example\n\n```typescript\n/**\n * Compressing all files from folder images to jpg with widths of 800px\n * and add '-min' to converted filenames,\n * saving all compressed images to folder compressed.\n */\n\nimport { glob } from 'glob';\nimport { compressImages } from 'image-down';\n\nconst filePaths = await glob('images/*');\nawait compressImages(filePaths, {\n  width: 800,\n  format: 'jpg',\n  suffix: 'min',\n  output: './compressed',\n  onProgress({ progress }) {\n    console.log(`Saved ${progress.filename}.`);\n  },\n});\n```\n\n### `compressImage`\n\nYou can use `compressImage` if you only want to compress 1 image.\n\n```typescript\nimport { compressImage } from 'image-down';\n\nconst compressedBuffer = await compressImage('./image/image1.jpg', {\n  percentage: 50,\n  returnBuffers: true,\n});\n```\n\nPlease note that `compressImage` returns directly the Buffer when `options.returnBuffers` is set to `true`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyinyanfr%2Fimage-down","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyinyanfr%2Fimage-down","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyinyanfr%2Fimage-down/lists"}