Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to oxipng 7.0.0 #6

Merged
merged 5 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
309 changes: 201 additions & 108 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyoxipng"
version = "6.0.0"
version = "7.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -10,4 +10,4 @@ crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.17.2", features = ["extension-module"] }
oxipng = { version = "6.0.*" }
oxipng = { version = "7.0.*" }
169 changes: 77 additions & 92 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ oxipng.optimize("/path/to/image.png", level=6, backup=True, interlace=1)
| `pretend` | Don't actually write any output file, just calculate the best results | `bool` | `False` |
| `force` | Write to output even if there was no improvement in compression | `bool` | `False` |
| `preserve_attrs` | Ensure the output file has the same permissions as the input file | `bool` | `False` |
| `filter` | Which filters to try on the file [0-5] | `set[int]` | `{0,5}` |
| `filter` | Which filters to try on the file. Use Use enum values from `oxipng.RowFilter` | `set=[RowFilter.None]` | `{RowFilter.None}` |
| `interlace` | Whether to change the interlacing type of the file. `0` means disable interlacing. `1` means enable it. `None` means leave as is. | `int \| None` | `None` |
| `alphas` | Alpha filtering strategies to use. Use enum values from `oxipng.AlphaOptim` | `set[AlphaOptim]` | `{AlphaOptim.NoOp}` |
| `bit_depth_reduction` | Whether to attempt bit depth reduction | `bool` | `True` |
Expand All @@ -84,7 +84,7 @@ oxipng.optimize("/path/to/image.png", level=6, backup=True, interlace=1)
| `grayscale_reduction` | Whether to attempt grayscale reduction | `bool` | `True` |
| `idat_recoding` | If any type of reduction is performed, IDAT recoding will be performed regardless of this setting | `bool` | `True` |
| `strip` | Which headers to strip from the PNG file, if any. Specify with `oxipng.Headers` | `Headers` | `Headers.none()` |
| `deflate` | Which DEFLATE algorithm to use. Specify an instance of `oxipng.Zlib`, `oxipng.Zopfli` or `oxipng.Libdeflater` | `Zlib \| Zopfli \| Libdeflater` | `Zlib()` |
| `deflate` | Which DEFLATE algorithm to use. Specify an instance of `oxipng.Libdeflater` or `oxipng.Zopfli` | `Libdeflater \| Zopfli` | `Libdeflater()` |
| `use_heuristics` | Whether to use heuristics to pick the best filter and compression. Intended for use with `level=1` | `bool` | `False` |
| `timeout` | Maximum amount of time to spend (in milliseconds) on optimizations. Further potential optimizations are skipped if the timeout is exceeded. | `int \| None` | `None` |

Expand All @@ -100,6 +100,19 @@ Initialize the `alphas` set with any of the following enum options:
- `oxipng.AlphaOptim.Down`
- `oxipng.AlphaOptim.Left`

### filter

Initialize the `filter` set with any of the following enum options:

- `oxipng.RowFilter.None`
- `oxipng.RowFilter.Sub`
- `oxipng.RowFilter.Up`
- `oxipng.RowFilter.Average`
- `oxipng.RowFilter.Paeth`
- `oxipng.RowFilter.Bigrams`
- `oxipng.RowFilter.BigEnt`
- `oxipng.RowFilter.Brute`

### strip

Initialize the `strip` option by calling one of the following static methods
Expand All @@ -116,21 +129,16 @@ provided by the `oxipng.Headers` class.
### deflate

Initialize the `deflate` option by instantiating one of the following classes:

- `Zlib(compression: list[int] = [9], strategies: list[int] = [0, 1, 2, 3], window: int = 15)`
- `compression`: Which zlib compression levels to try on the file (1-9)
- `strategies`: Which zlib compression strategies to try on the file (0-3)
- `window`: Window size to use when compressing the file, as `2^window` bytes (8-15). Doesn't affect compression but may affect speed and memory usage
- `Libdeflater(compression: int)`
- `compression`: compression level [1-12]
- `Zopfli(iterations: int)`
- `iterations`: The number of compression iterations to do.
- `Libdeflater()`
- `iterations`: The number of compression iterations to do.

Examples:

```py
oxipng.optimize("in.png", deflate=Zlib(compression=[7, 8], window=8))
oxipng.optimize("in.png", deflate=Libdeflater(2))
oxipng.optimize("in.png", deflate=Zopfli(3))
oxipng.optimize("in.png", deflate=Libdeflater())
```

## Development
Expand Down
Loading