Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: boidolr/pre-commit-images
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.7.0
Choose a base ref
...
head repository: boidolr/pre-commit-images
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.7.1
Choose a head ref

Commits on Apr 14, 2024

  1. Copy the full SHA
    d961da2 View commit details

Commits on Apr 15, 2024

  1. Copy the full SHA
    5e6d93d View commit details

Commits on Apr 17, 2024

  1. Copy the full SHA
    75870fa View commit details

Commits on Apr 18, 2024

  1. Copy the full SHA
    cf5f524 View commit details

Commits on Apr 19, 2024

  1. Copy the full SHA
    b654bd3 View commit details

Commits on Apr 20, 2024

  1. chore: reorder hooks

    Formatting should happen after fixes,
    to reduce round trips
    boidolr committed Apr 20, 2024
    Copy the full SHA
    d37fcc6 View commit details

Commits on Apr 22, 2024

  1. Copy the full SHA
    fba6cf0 View commit details
  2. Copy the full SHA
    ec51723 View commit details

Commits on Apr 25, 2024

  1. Copy the full SHA
    7c43792 View commit details
  2. Copy the full SHA
    ee10559 View commit details
  3. Copy the full SHA
    f3c0c26 View commit details

Commits on Apr 26, 2024

  1. Copy the full SHA
    1f3faef View commit details

Commits on May 4, 2024

  1. Copy the full SHA
    b1bc9c2 View commit details

Commits on May 8, 2024

  1. Copy the full SHA
    24560e7 View commit details
  2. Copy the full SHA
    ffee105 View commit details

Commits on May 9, 2024

  1. Copy the full SHA
    6961eae View commit details
  2. Copy the full SHA
    cae098a View commit details

Commits on May 10, 2024

  1. Copy the full SHA
    886bbd0 View commit details

Commits on May 13, 2024

  1. Copy the full SHA
    d118c58 View commit details

Commits on May 18, 2024

  1. Copy the full SHA
    294cb8b View commit details

Commits on May 20, 2024

  1. Copy the full SHA
    0548353 View commit details

Commits on May 21, 2024

  1. chore: release version 1.7.1

    boidolr committed May 21, 2024
    Copy the full SHA
    34305f9 View commit details
Showing with 56 additions and 19 deletions.
  1. +3 −3 .github/workflows/codeql-analysis.yml
  2. +2 −2 .github/workflows/continous-integration.yml
  3. +1 −1 .github/workflows/create-release.yml
  4. +15 −9 .pre-commit-config.yaml
  5. +12 −0 .scripts/gifsicle.sh
  6. +22 −3 README.md
  7. +1 −1 pyproject.toml
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -20,12 +20,12 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4

- name: Initialize CodeQL
uses: github/codeql-action/init@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3
uses: github/codeql-action/init@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3
with:
languages: python

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@4355270be187e1b672a7a1c7c7bae5afdc1ab94a # v3
uses: github/codeql-action/analyze@b7cec7526559c32f1616476ff32d17ba4c59b2d6 # v3
4 changes: 2 additions & 2 deletions .github/workflows/continous-integration.yml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4

- uses: boidolr/actions/python-pip-env@main
with:
@@ -37,5 +37,5 @@ jobs:
precommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- uses: boidolr/actions/run-precommit@main
2 changes: 1 addition & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ jobs:
github.actor == 'boidolr'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- name: Create release for tag
run: |
TAG=$(echo "${{ github.ref }}" | cut -c 11-)
24 changes: 15 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -7,20 +7,26 @@
# Update repos:
# pre-commit autoupdate
---
exclude: ^tests/test\.[a-z]+$
repos:
- repo: https://github.com/boidolr/pre-commit-images
rev: v1.6.0
rev: v1.7.0
hooks:
- id: optimize-avif
exclude: ^tests
- id: optimize-jpg
exclude: ^tests
- id: optimize-png
exclude: ^tests
- id: optimize-svg
exclude: ^tests
- id: optimize-webp
exclude: ^tests

# possible way to run locally installed tools
- repo: local
hooks:
- id: gifsicle
name: gifsicle - local
entry: .scripts/gifsicle.sh
language: script
pass_filenames: true
types: [gif]

- repo: https://github.com/boidolr/pre-commit-text
rev: v1.2.15
@@ -41,13 +47,13 @@ repos:
args: [--autofix, --indent=4, --no-sort-keys]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
rev: v0.4.4
hooks:
- id: ruff-format
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
rev: v1.10.0
hooks:
- id: mypy
12 changes: 12 additions & 0 deletions .scripts/gifsicle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -uo pipefail

_=$(command -v gifsicle > /dev/null)
EXIT="$?"
set -e

if [[ "$EXIT" == "0" ]]; then
gifsicle -O3 -i --batch "${@:1}"
else
echo "Skipping gifsicle as it is not installed"
fi
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,21 +5,24 @@ pre-commit-images
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
================

Git hooks to optimize and manipulate images based on the [pre-commit](https://github.com/pre-commit/pre-commit) framework. For supported image formats see the list of available hooks below.
Scripts that can work as `it` hooks to optimize and manipulate images.
These scripts can be called directly or with the provided configration for the [pre-commit](https://github.com/pre-commit/pre-commit) framework.
For details see below.


## Using pre-commit-images with pre-commit

Add this to your `.pre-commit-config.yaml`:
```
- repo: https://github.com/boidolr/pre-commit-images
rev: v1.7.0 # Use the ref you want to point at
rev: v1.7.1 # Use the ref you want to point at
hooks:
- id: optimize-png
# - id: ...
```
For an extended example see [`.pre-commit-config.yaml`](.pre-commit-config.yaml).

## Available hooks
### Available hooks

- **`optimize-avif`**: Compress `avif` images.
- `--threshold` can be used to configure which size difference should be used to keep the image.
@@ -41,6 +44,22 @@ For an extended example see [`.pre-commit-config.yaml`](.pre-commit-config.yaml)
- `--height` new height of images.


## Using scripts directly

Install the package to get access to the scripts defined as command line entry points in [`pyproject.toml`](./pyproject.toml).
The scripts accept the arguments given for the pre-commit hooks. Additionally they exepect to receive the file names to work on.

An example invocation could be `optimize-avif tests/test.avif`.

Available entry points are identical to the pre-commit hooks:
- `optimize-avif`
- `optimize-jpg`
- `optimize-png`
- `optimize-svg`
- `optimize-webp`
- `resize`


## References

These hooks only work because of other projects:
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ authors = [
urls = {"Respository" = "https://github.com/boidolr/pre-commit-images"}
license = {file = "LICENSE"}
readme = "README.md"
version = "1.7.0"
version = "1.7.1"
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",