{"id":15700555,"url":"https://github.com/magicdawn/handy-img","last_synced_at":"2025-05-07T21:45:36.463Z","repository":{"id":47373697,"uuid":"264613853","full_name":"magicdawn/handy-img","owner":"magicdawn","description":"handy img tool and API","archived":false,"fork":false,"pushed_at":"2024-11-08T17:39:02.000Z","size":1909,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T21:45:30.484Z","etag":null,"topics":["compress","handy-img","img","mozjpeg","sharp","squoosh"],"latest_commit_sha":null,"homepage":"","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/magicdawn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-05-17T08:12:24.000Z","updated_at":"2024-11-08T17:39:06.000Z","dependencies_parsed_at":"2023-12-16T14:46:51.532Z","dependency_job_id":"10247359-ea8d-4fcb-a01d-5d00057a1c61","html_url":"https://github.com/magicdawn/handy-img","commit_stats":{"total_commits":87,"total_committers":1,"mean_commits":87.0,"dds":0.0,"last_synced_commit":"d5a87441af794dafe93b587eba495df0f577169e"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fhandy-img","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fhandy-img/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fhandy-img/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicdawn%2Fhandy-img/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicdawn","download_url":"https://codeload.github.com/magicdawn/handy-img/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252961858,"owners_count":21832192,"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":["compress","handy-img","img","mozjpeg","sharp","squoosh"],"created_at":"2024-10-03T19:50:05.745Z","updated_at":"2025-05-07T21:45:36.441Z","avatar_url":"https://github.com/magicdawn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- AUTO_GENERATED_UNTOUCHED_FLAG --\u003e\n\n# handy-img\n\n\u003e handy img tool and API\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/magicdawn/handy-img/ci.yml?style=flat-square\u0026branch=main)](https://github.com/magicdawn/handy-img/actions/workflows/ci.yml)\n[![Coverage Status](https://img.shields.io/codecov/c/github/magicdawn/handy-img.svg?style=flat-square)](https://codecov.io/gh/magicdawn/handy-img)\n[![npm version](https://img.shields.io/npm/v/handy-img.svg?style=flat-square)](https://www.npmjs.com/package/handy-img)\n[![npm downloads](https://img.shields.io/npm/dm/handy-img.svg?style=flat-square)](https://www.npmjs.com/package/handy-img)\n[![npm license](https://img.shields.io/npm/l/handy-img.svg?style=flat-square)](http://magicdawn.mit-license.org)\n\n## compress Features\n\n- [x] target mozjpeg / webp are supported. `@squoosh/cli` supports more format.\n- [x] Node.js native addon, better performance than squoosh WASM version.\n- [x] batch process, support `--files` glob or dir mode `--dir`\n- [x] parallel compress. set your `UV_THREADPOOL_SIZE=64` (see [this](https://www.sebastienvercammen.be/your-libuv-thread-pool-size-is-too-small/)) and handy-img will use this as concurrency.\n\n## Install\n\n```sh\n$ pnpm add -g handy-img\n```\n\n## or invoke without install\n\n```sh\n# pnpm, recommend\npnpm dlx handy-img\n# or yarn 2\nyarn dlx handy-img\n\n# or npx/pnpx\nnpx handy-img\npnpx handy-img\n```\n\n## cli\n\njust type `himg` or `handy-img`\n\n```txt\n$ himg\nhimg \u003c命令\u003e\n\n命令：\n  himg compress \u003cfile\u003e  compress file                               [aliases: c]\n  himg info \u003cfile\u003e      show info for file                          [aliases: i]\n\n选项：\n  --version  显示版本号                                                   [布尔]\n  --help     显示帮助信息                                                 [布尔]\n\n缺少 non-option 参数：传入了 0 个, 至少需要 1 个\n```\n\n### `himg compress` or `himg c`\n\n```\n$ himg c -h\nCompress img\n\n$ handy-img compress\n\n━━━ Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n  -f,--files #0                files as input\n  --ignore-case                ignore case for -f,--files, default true\n  --glob-cwd #0                cwd used in glob\n  -t,--tokens,--show-tokens    show available tokens\n  -o,--output #0               output patterns\n  --codec #0                   Allowed codec: `mozjpeg` or `webp`\n  --metadata                   keep metadata(only available with --codec webp)\n  -q,--quality #0              quality\n  -d,--dir #0                  compress whole dir, and output to dir_compressed\n  --dir-suffix #0              suffix to append to original dir name when using -d,--dir mode\n  -y,--yes                     exec commands, default false(only preview commands, aka dry run)\n```\n\n#### flags\n\n| flag                        | desc                                                             | default       | remark                                               |\n| --------------------------- | ---------------------------------------------------------------- | ------------- | ---------------------------------------------------- |\n| `-f,--files`                | specify input,                                                   |               | glob supported, see globby \u0026 fast-glob               |\n| `--ignore-case`             | ignore case when glob input                                      | `true`        |                                                      |\n| `--glob-cwd`                | cwd of `-f,--files` provided                                     | `pwd`         |                                                      |\n| `-t,--tokens,--show-tokens` | show available tokens                                            |               | help you to decide the `-o,--output` flag, see below |\n| `-o,--output`               | output pattern                                                   |               |                                                      |\n| `--codec`                   | Allowed codec: `mozjpeg` or `webp` or `mozjpeg-raw`              | `mozjpeg`     |                                                      |\n| `--metadata`                | keep metadata(not available with `--codec mozjpeg-raw`)          | `true`        | keep exif data                                       |\n| `-q,--quality`              | quality                                                          | `80`          | encode quality, `0-100`                              |\n| `-d,--dir`                  | compress whole dir, and output to dir_compressed                 |               |                                                      |\n| `--dir-suffix`              | suffix to append to original dir name when using -d,--dir mode   | `_compressed` |                                                      |\n| `-O,--other,--other-files`  | how to handle other files in dir mode                            |               | `move` or `copy` none img files to newly created dir |\n| `-y,--yes`                  | exec commands, default false(only preview commands, aka dry run) | `false`       |                                                      |\n\n## Usage\n\n### `-d`, use dir mode\n\n```sh\nhimg c -d ./your-dir-here -y\n```\n\nglob all imgs in the dir you provided, and output to a new directory, which name is original name + dir suffix\nand img will keep same structure.\n\n```sh\n# example\nhimg c -d dir -q 85 -y\n```\n\n![image](https://user-images.githubusercontent.com/4067115/227441783-407dab2e-9eb2-4be8-bfaf-635bee4787ae.png)\n\n### about `-y,--yes`\n\nwithout this option, you will see what input will be processed and what file will be generated.\nbut the compress action will not really execute. aka dry run.\n\n```sh\n--------------------------------------------------------------------------------\n  current previewing commands. After comfirmed, append -y or --yes flag to execute\n--------------------------------------------------------------------------------\n```\n\nit's like a safety guard for a gun\n\n### `-f,--files`, single or multiple files\n\n\u003cdetails\u003e\n\t\u003csummary\u003euse `-f,--files` if you have to\u003c/summary\u003e\n\n#### 1.decide input\n\n![image](https://user-images.githubusercontent.com/4067115/180050266-1e3a1f46-0e8d-486a-8ea2-8c2dac604a9f.png)\n\n#### 2.then use `-t,--tokens,--show-tokens` show available tokens\n\n![image](https://user-images.githubusercontent.com/4067115/180050603-bb4ea54d-cad6-4c91-b86d-0f6d48cde788.png)\n\n#### 3.write your output pattern \u0026 preview\n\nexample pattern `himg c -f './*.jpg' -t -o ':dir/:name_compressed.:ext'`\n![image](https://user-images.githubusercontent.com/4067115/180050746-084418e3-1ac4-43d9-9e7e-5fe07728a60c.png)\n\nexample pattern `himg c -f './*.jpg' -t -o ':dir/compressed/:name.:ext'`\n![image](https://user-images.githubusercontent.com/4067115/180050958-59196349-3693-4fef-9f92-c9520babccf3.png)\n\n#### 4.use `-y,--yes` to execute\n\n\u003c/details\u003e\n\n## Which codec \u0026 quality should I choose ?\n\nSee\n\n- https://tsev.dev/posts/2023-11-10-should-avif-be-the-dominant-image-format/\n- AND https://github.com/magicdawn/magicdawn/issues/170#issuecomment-1858817900\n\n## Changelog\n\n[CHANGELOG.md](CHANGELOG.md)\n\n## License\n\nthe MIT License http://magicdawn.mit-license.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicdawn%2Fhandy-img","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicdawn%2Fhandy-img","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicdawn%2Fhandy-img/lists"}