{"id":28726767,"url":"https://github.com/boidolr/pre-commit-images","last_synced_at":"2025-06-15T13:08:55.591Z","repository":{"id":40254274,"uuid":"447335016","full_name":"boidolr/pre-commit-images","owner":"boidolr","description":"Scripts for image optimization usable as pre-commit hooks","archived":false,"fork":false,"pushed_at":"2025-05-29T13:59:26.000Z","size":625,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-29T15:01:43.673Z","etag":null,"topics":["avif","git-hooks","image-optimization","jpeg","png","pre-commit","svg"],"latest_commit_sha":null,"homepage":"","language":"Python","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/boidolr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-12T18:52:29.000Z","updated_at":"2025-05-29T13:59:29.000Z","dependencies_parsed_at":"2023-02-17T03:15:38.126Z","dependency_job_id":"5d7fa846-aa80-4ea1-8ddd-30ed986bc299","html_url":"https://github.com/boidolr/pre-commit-images","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/boidolr/pre-commit-images","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boidolr%2Fpre-commit-images","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boidolr%2Fpre-commit-images/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boidolr%2Fpre-commit-images/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boidolr%2Fpre-commit-images/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boidolr","download_url":"https://codeload.github.com/boidolr/pre-commit-images/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boidolr%2Fpre-commit-images/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259981476,"owners_count":22941149,"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":["avif","git-hooks","image-optimization","jpeg","png","pre-commit","svg"],"created_at":"2025-06-15T13:08:52.695Z","updated_at":"2025-06-15T13:08:55.566Z","avatar_url":"https://github.com/boidolr.png","language":"Python","readme":"pre-commit-images\n[![tag](https://img.shields.io/github/v/tag/boidolr/pre-commit-images?sort=semver)](https://github.com/boidolr/pre-commit-images/tags)\n![python](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fboidolr%2Fpre-commit-images%2Fmain%2Fpyproject.toml)\n[![Build](https://github.com/boidolr/pre-commit-images/actions/workflows/continous-integration.yml/badge.svg)](https://github.com/boidolr/pre-commit-images/actions/workflows/continous-integration.yml)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n================\n\nScripts that can work as `git` hooks to optimize and manipulate images.\nThese scripts can be called directly or with the provided configuration for the [pre-commit](https://github.com/pre-commit/pre-commit) framework.\nFor details see below.\n\n\n## Using pre-commit-images with pre-commit\n\nAdd this to your `.pre-commit-config.yaml`:\n```\n    -   repo: https://github.com/boidolr/pre-commit-images\n        rev: v1.8.8  # Use the ref you want to point at\n        hooks:\n        -   id: optimize-png\n        # -   id: ...\n```\nFor an extended example see [`.pre-commit-config.yaml`](.pre-commit-config.yaml).\n\n### Available hooks\n\n- **`optimize-avif`**: Compress `avif` images.\n    - `--threshold` can be used to configure which size difference should be used to keep the image.\n    - `--quality` to configure minimum quality setting (best: 100, worst: 0).\n    - `--effort` to set the quality/speed tradeoff (slowest: 0, fastest: 10).\n- **`optimize-jpg`**: Compress `jpeg` images.\n    - `--threshold` can be used to configure which size difference should be used to keep the image.\n    - `--quality` can be used to configure quality setting for a JPG image.\n- **`optimize-png`**: Compress `png` images.\n    - `--threshold` can be used to configure which size difference should be used to keep the image.\n- **`optimize-svg`**: Compress `svg` images.\n    - `--threshold` can be used to configure which size difference should be used to keep the image.\n- **`optimize-webp`**: Compress `webp` images.\n    - `--threshold` can be used to configure which size difference should be used to keep the image.\n    - `--lossless` switch to lossless compression.\n    - `--quality` can be used to configure quality setting for lossy compression or effort to spend on lossless compression.\n- **`resize`** (experimental): Resize `avif`, `jpeg`, `png` and `webp` images with fixed dimensions. Required options:\n    - `--width` new width of images.\n    - `--height` new height of images.\n\n\n## Using scripts directly\n\nInstall the package to get access to the scripts defined as command line entry points in [`pyproject.toml`](./pyproject.toml).\nThe scripts accept the arguments given for the pre-commit hooks. Additionally they exepect to receive the file names to work on.\n\nAn example invocation could be `uvx --from 'git+https://github.com/boidolr/pre-commit-images.git[avif]' optimize-avif tests/test.avif`.\n\nAvailable entry points are identical to the pre-commit hooks:\n- `optimize-avif`\n- `optimize-jpg`\n- `optimize-png`\n- `optimize-svg`\n- `optimize-webp`\n- `resize`\n\n\n## References\n\nThese hooks only work because of other projects:\n\n- [PIL](https://github.com/python-pillow/Pillow)\n- [pillow-avif-plugin](https://github.com/fdintino/pillow-avif-plugin)\n- [scour](https://github.com/scour-project/scour)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboidolr%2Fpre-commit-images","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboidolr%2Fpre-commit-images","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboidolr%2Fpre-commit-images/lists"}