Commit graph

57 commits

Author SHA1 Message Date
Luracasmus
33cea5603e
Apply some Clippy lints (#744)
Let me know if I should add these to the `Cargo.toml`.

All `cargo test` tests pass on the latest x86_64-unknown-linux-gnu
nightly.

---------

Co-authored-by: Alejandro González <me@alegon.dev>
2025-12-06 16:06:35 +01:00
andrews05
14532e8bf5
BC breaks for v10 (#715)
This is a collection of all the BC breaks mentioned in #714, except for
11 which I'm not including for now.

Fixes #658.
Fixes #660.

It might be best to review each commit individually, referencing the
notes in #714 and #660 (I just didn't want to create a dozen separate
PRs).
2025-09-20 17:16:22 +02:00
andrews05
71290acc62
Reduce memory usage of fast evaluation (#713)
This is an experiment I started a while ago before life happened. It
reduces memory usage of fast evaluation (-o2 and lower), bringing it
inline with normal (slow) evaluation. It does this by not retaining the
filtered image data of the evaluations, but instead retaining the row
filters that were used in each line so it can be quickly re-filtered
when required. This does incur a tiny performance penalty, but it's
negligible even at `-o0`.
Although this is fully functional, there are a few rough spots in the
code so I'm just opening it as a draft for now.

```
PR -sao6
       70.08 real       614.36 user         2.66 sys
          2024243200  maximum resident set size
          1839339520  peak memory footprint

PR -sao2
       11.16 real        60.85 user         1.33 sys
          1982562304  maximum resident set size
          1842173824  peak memory footprint

PR -sao2 -t1
       55.11 real        53.85 user         0.76 sys
           429457408  maximum resident set size
           245008064  peak memory footprint

master -sao6
       67.70 real       616.07 user         2.72 sys
          2043379712  maximum resident set size
          1838340416  peak memory footprint

master -sao2
       11.53 real        60.63 user         1.25 sys
          2753396736  maximum resident set size
          2283741440  peak memory footprint

master -sao2 -t1
       54.29 real        53.55 user         0.72 sys
           626311168  maximum resident set size
           305252544  peak memory footprint
```

Note that this involves some refactoring of `RowFilter` and the new
`FilterStrategy`. These are breaking changes so it will ultimately be
destined for v10. One advantage to this new structure is it opens the
door for future changes such as allowing the Brute strategy to take a
parameter for the number of lines.
2025-09-19 20:36:17 +02:00
andrews05
8ebb5e6dfd
Cleanup tests (#656)
I've replaced a few tests with synthetic images and removed a number
that I don't believe are relevant anymore.

I've also removed the #553 test without replacement as I don't know how
to synthesise a replacement and the issue is still open anyway.

Going forward I think we should avoid adding any new "issue" tests and
instead synthesise something suitable in one of the other collections.

Closes #655.
2024-12-02 20:58:01 +01:00
Alejandro González
0608ab9cab
Fix some new nightly Clippy lints and run rustfmt with prettier config 2024-02-20 19:12:35 +01:00
andrews05
98fd4de30a
Reduce size of release binary (#592)
This PR makes 3 changes that together reduce binary size by around 25%:
- Sets lto="fat" in cargo.toml
- Sets panic="abort" in cargo.toml
- Sets location-detail=none in RUSTFLAGS

Closes #571

An unrelated change: I've replaced the zopfli test file with a smaller
one that runs much faster, as well as removing the slow test for
issue-133 which was related to an older alpha optimisation that is no
longer relevant.
2024-02-20 19:02:12 +01:00
Andrew
0b3302316b Tidy some issue tests 2023-10-10 11:03:08 +13:00
Andrew
b808807198 Add test 2023-10-10 11:03:08 +13:00
andrews05
462e982784
Move file-specific options under OutFile (#529)
This PR is addressing #220. It's not super important but it's a breaking
change, so if it's something we want to do then I thought I should get
it in now before the next release.

- [x] pretend can become another variant of OutFile, probably
OutFile::None, as that's what it essentially is - just another output
destination and not a separate option
- [x] ~~backup and~~ preserve_attrs should become properties of
OutFile::Path variant (so that it would contain Path { path, ~~backup,~~
preserve_attrs }) as they don't have any effect on any other output and
so semantically belong there best

Closes #220
2023-09-25 11:15:13 +02:00
andrews05
39b00910ae
Use stronger compression in eval (#509) 2023-07-08 18:54:58 -04:00
andrews05
96122fa45a
Expand low depths to 8-bit (#516)
* Keep track of number of pixels in each scanline

* Expand depth to 8-bit

* Attempt expand bit depth

* Simplify tracking of reduction_occurred

* Fix test

* Simplify depth handling in reductions

* Add tests for disabled reductions
2023-06-18 01:32:47 -04:00
andrews05
ea5f1884be
Refactor aux chunk handling (#505) 2023-05-21 15:34:23 -04:00
andrews05
2f622fc7bd
Minor reduction improvements (#502)
* Fix bKGD conversion from gray to palette

* Allow grayscale reduction from 16 to 4 or less

* Refactor reduction evaluation sequence

* Separate palette into new file
2023-05-07 17:46:58 -04:00
Andrew
798a120926 Include PLTE/tRNS size in evaluations 2023-04-29 01:20:22 -04:00
andrews05
c97572be3e
ColorType Refactor (#500)
* Refactor ColorType
Move transparency and palette data into the ColorType

* Fixup tests

* Make more use of helper functions

* Change BitDepth to u8 representation with TryFrom

* Fix clippy lints

* Don't use unstable language features

* Restore documentation on transparency/palette
2023-04-27 19:49:54 -04:00
Andrew
d43e63f562 Remove test 167 which is no longer relevant 2023-01-06 15:35:05 -05:00
andrews05
2599b9fe82
Tweaks to interlacing and format display (#476) 2022-12-12 09:54:35 -05:00
andrews05
131a3c6af7
🚀 Revamp alpha optimisation (#475) 2022-12-10 21:14:50 -05:00
andrews05
54ee621e41
Fix Grayscale depth reduction with tRNS (#470) 2022-12-08 06:11:26 -05:00
andrews05
bd5a0b526b
More Reductions (#468)
* Add test for issue 195

* Reduce grayscale alpha to palette

* Black alpha before color type reductions
2022-12-07 13:22:13 -05:00
andrews05
3365aca12f
Palette reduction fixes (#466)
* Verify bKGD in tests

* Don't truncate bKGD on output

* Make sure correct bKGD is retained

* Update safe chunk list

* Perform strip first

* Check entire palette map
2022-12-07 07:49:52 -05:00
andrews05
a41d7de348
New filter strategies (#461)
* Refactor filters as enum

* Include filter byte in filter output

* Add entropy filter

* Add bigrams filter

* Add bigram entropy filter

* Add brute filter

* Replace bit-vec

* Add tests and benches

* Show filters in help

* Use FxHasher in color to palette

* Use windows function for minor improvement
2022-11-19 08:49:25 -05:00
Josh Holmer
06e3feeee1 Use separate file for issue_182 test
Closes #412
2021-07-11 23:10:57 -04:00
Rémi Lauzier
286aaffa31 small fix 2021-06-24 19:47:21 -04:00
Rémi Lauzier
91a18ebe97 Fix some clippy warnings 2021-06-24 15:57:41 -04:00
Ingvar Stepanyan
23ae9c302f
Switch to standard logging library (#218)
This allows to configure or compile away logging in the library from a single place in Rust apps.

For the CLI side, the usage and output remained the same, except it's now colour-coded.

Fixes #217.
2020-04-18 18:33:48 -04:00
Ingvar Stepanyan
878bbedb37
Improve performance consistency (#202)
* Improve performance consistency

Switch from HashMap / HashSet to IndexMap / IndexSet for consistent iteration order of various options and, as a result, more predictable performance.
2020-03-31 21:54:05 -04:00
Felix Hanau
4adcc5e14a Interlacing fixes (#182)
* Fix decoding interlaced images with height or width <= 2

* Add Issue 175 test case

* Deinterlace tiny images correctly
2019-07-24 09:16:13 -04:00
Felix Hanau
56b94542a6 Fix decoding interlaced images with height or width <= 2 (#175) 2019-06-27 13:44:34 -04:00
Josh Holmer
c60bd82da7 Add test case for #171 2019-06-20 14:07:47 -04:00
Josh Holmer
9d8ce5e4ee Disable large image test for 32-bit systems
Closes #176
2019-06-20 13:38:59 -04:00
Josh Holmer
7bd7c0cfc9 Bump image crate to handle large images
Closes #167 and #168
2019-03-26 14:14:01 -04:00
Josh Holmer
d86bc80f43 Prepare for next release 2019-02-01 17:27:03 -05:00
Kornel
9af874d21b Make reductions return a new uncompressed image (#158)
* Fix verbose message

* No cloning when restoring original data

* Make reductions return a new uncompressed image

Partially fixes #145

* Async reduction evaluator

* Assert

* Faster bit depth check

* Also try 4-bit depth for small-depth images

* Skip test when using miniz

* Ensure palette is trimmed after depth reduction

Fixes #159

* Fudge factor for reductions to prefer better reductions even if gzip estimation says otherwise
2019-01-27 03:22:49 -05:00
Josh Holmer
918c52eed8 Fix more nonstandard sBIT headers
Closes #153
2018-12-02 00:13:30 -05:00
Joshua Holmer
041c433ccb Handle non-standard sBIT headers
Closes #141
2018-11-26 13:10:21 -05:00
Joshua Holmer
87e738dda2 Fix incorrect detection of images that can reduce bit depth
Closes #140
2018-10-11 08:29:48 -04:00
Josh Holmer
bb1737928e Fix RGB to Indexed reduction if transparency pixel exists
Closes #129
2018-08-11 23:33:55 -04:00
Josh Holmer
71d0f6fa31 Fix more issues with alpha optim on interlaced images
Closes #133
2018-08-11 20:27:45 -04:00
Josh Holmer
7303b94afc Fix issue with alpha optim on interlaced images
Closes #113
2018-07-27 23:03:36 -04:00
Josh Holmer
d110949d2a Version 2.0.0 2018-07-20 19:19:20 -04:00
Kornel
c99b3778b2 Expose only one internal module specifically for tests (#123)
Closes #98
2018-07-17 23:38:11 -04:00
Kornel
cb52d8466a Reading from stdin (#118) 2018-07-12 07:54:06 -04:00
Kornel
ebf541219c DRYyer tests (#117) 2018-07-10 22:38:49 -04:00
Kornel
55a095d536 Enum for stdout writing flag (#110) 2018-07-10 18:41:06 -04:00
Kornel
e83762d3b1 Remove deprecated Error::description (#109) 2018-07-06 07:26:49 -04:00
Josh Holmer
e3ba535a79 Add some changes and fixes around how the output file is handled
See changelog for details
2018-01-10 20:54:15 -05:00
Josh Holmer
f8c62de6c0 Fix unfiltering of first scan line in each pass of an interlaced input file
Closes #92
2017-12-23 00:36:41 -05:00
Josh Holmer
4d62f9f7f9 Fix failure to optimize on certain grayscale images
Closes #89
2017-11-21 12:38:33 -05:00
Josh Holmer
e17f911334 Fix a bug in palette reduction at less than 8 bits per pixel
Closes #82
2017-09-11 18:27:28 -04:00