Ingvar Stepanyan
a497513d89
Move Zlib-specific options under Zlib compressor ( #210 )
...
Make it statically obvious that they're not compatible with other compressors.
2020-04-17 10:05:13 -04:00
Ingvar Stepanyan
e8ff6f7526
Remove unused (outdated?) options ( #212 )
...
Co-authored-by: Josh Holmer <jholmer.in@gmail.com>
2020-04-17 05:16:18 -04:00
Ingvar Stepanyan
bb332fa6d7
Don't override global rayon pool ( #211 )
...
Rayon uses a singleton global pool.
By default it's set to a regular spawn handler with number of logical CPU cores, but it can be overridden by Rust applications to customize number of threads, spawn handlers, exit handlers and other options.
Such customization should be usually done at the app level, because if a single library initialises the global pool, then Rayon will prevent any further overrides and they will error out. This can cause conflicts between libraries or library and user code and make them impossible to use together.
Hence, I've removed the `threads` option from the `Options` struct and instead moved initialisation to the CLI part of the codebase (main.rs).
Users of the library that didn't depend on custom `threads` number can keep using it as before - they'll still get same number of threads as number of logical CPU cores, while users who need fine-tuning, can do that by customizing rayon pool themselves at the top level of the app.
Note: another alternative to keep the option could've been to use `ThreadPoolBuilder::build` + `ThreadPool::install` to use a local pool just within OxiPNG, but that would ignore any customizations made by users in top-level pool and would prevent usage on targets that require custom spawn handlers like WebAssembly. As such, I've decided to avoid it.
Co-authored-by: Josh Holmer <jholmer.in@gmail.com>
2020-04-17 04:49:40 -04:00
Ingvar Stepanyan
4fd9203800
Bring back RefCell
...
It was accidentally removed as part of #208 .
Fixes #214 .
2020-04-16 18:31:24 -04:00
Ingvar Stepanyan
9b8361171f
Revert "Unbreak no-default-features"
...
This reverts commit 4ef92089d5 .
2020-04-16 18:31:24 -04:00
Josh Holmer
139b2878d0
Fix benchmark compilation
...
Closes #197
2020-04-15 13:26:28 -04:00
Josh Holmer
53368fcbbf
Reexport indexmap structs
2020-04-15 13:26:28 -04:00
Josh Holmer
4ef92089d5
Unbreak no-default-features
...
In order to avoid problems with mutable references,
the approach is to use the eval sender for non-parallel.
Computations will still be done synchronously
with the fake synchronous rayon module.
2020-04-15 13:26:28 -04:00
Josh Holmer
43735086d1
Migrate to Github Actions
...
Closes #206
2020-04-15 13:26:28 -04:00
Ingvar Stepanyan
63e36ed43f
Simplify comparer ( #208 )
...
* Skip baselines earlier in the evaluator
We know that we'll throw them away anyway, so there is no point in even sending them to Sender and comparing them with others once we used them for the best candidate size.
* Simplify comparison logic
2020-04-14 17:09:52 -04:00
Ingvar Stepanyan
f747269151
Respect deadline in miniz ( #200 )
2020-03-31 23:31:17 -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
Ingvar Stepanyan
121558bf5c
Add libdeflater as an option ( #203 )
...
libdeflater is a Rust wrapper around
[libdeflate](https://github.com/ebiggers/libdeflate ) - an alternative
heavily optimised library for deflate/zlib/gzip compression and
decompression that is intended for situations where upper bounds of the
output are well-known.
In my benchmarks on test files in the repo it has shown to be usually
both slightly faster and providing better compressed output than
cloudflare-zlib, but in some cases showing the opposite, so rather
than swapping defaults, it's currently provided as another option,
similarly to zopfli.
Since it's not strictly better in all cases, I'm not providing median
numbers, but you can check distribution histograms for time and size
differences here (all using `oxipng -o 6 -t 6 -P`):
https://docs.google.com/spreadsheets/d/1WOKgeYZBhLkQvMGAC36snN4azilElzOFhx63RJu0EZY/edit?usp=sharing
2020-03-31 20:24:57 -04:00
Kornel
681089f8c7
Remove the concept of size bias ( #199 )
...
Closes #198
2020-03-31 19:28:22 -04:00
Josh Holmer
bded03908f
Silence cognitive complexity warnings
2020-03-02 01:45:04 -05:00
Josh Holmer
b9dc9e72bb
Update image crate to 0.23
2020-03-02 01:44:53 -05:00
Josh Holmer
0e3c0b922d
Enable more clippy lints and fix some clippy issues
2020-01-19 05:22:14 -05:00
Josh Holmer
139d29cc9b
Version 2.3.0
2019-10-07 23:34:23 -04:00
Ingvar Stepanyan
659717cb1f
Allow usage on wasm32-unknown-unknown target ( #194 )
...
* Avoid using time API when we don't need it
This avoids a syscall to the time API when the result is ignored later anyway.
This allows to use the library with default options on wasm32-unknown-unknown, where the unimplemented syscall would panic otherwise.
* eval_send doesn't need to be an Option
We can drop the value manually, thus avoiding unwrap on each access.
* Keep single `use rayon::prelude::*`
If either `rayon` is already imported, then `rayon::prelude::*` should always resolve.
* Extract comparator
* Fully enable non-parallel mode
2019-09-25 13:01:53 -04:00
Kamal Ahmad
68db304a2a
Don't apply alpha optimizations unless --alpha is paseed ( #187 )
...
Closes #164
2019-09-24 11:33:50 -04:00
Kornel
e473958377
Palette sorting ( #193 )
...
* Implement alpha and luminosity palette sorting
* Also sort when reducing to palette
* Bump Rust version
* Color comparison
2019-09-10 18:13:05 -04:00
Kamal Ahmad
68b763bcdd
Reduce alloc in filtering/unfiltering by reusing buffers ( #191 )
2019-09-04 11:09:54 -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
Daniel Wong
4cb26d462e
Allow disabling all alpha optimizations ( #181 )
...
Fixes a bug where oxipng would crash if alpha optimizations were all disabled.
2019-07-23 14:21:46 -04:00
Kamal Ahmad
34ee78dbbc
Preallocate memory in reduced_alpha_to_up ( #180 )
2019-06-27 13:44:49 -04:00
Felix Hanau
56b94542a6
Fix decoding interlaced images with height or width <= 2 ( #175 )
2019-06-27 13:44:34 -04:00
Felix Hanau
c09e8f6d12
Make filter, zlib level and strategy deterministic ( #179 )
2019-06-27 10:05:35 -04:00
Josh Holmer
458e9f64a7
Fix --strip safe which was broken in 5b1121c9d
2019-06-19 15:27:43 -04:00
Josh Holmer
5b1121c9dd
Make order of chunks deterministic by sorting chunks
...
Closes #174
2019-06-18 13:29:17 -04:00
Felix Hanau
5dcfe44ccd
Fix info message and typos ( #172 )
2019-06-18 13:06:37 -04:00
Felix Hanau
cc290c0bdb
Fixes for grey scale reduction ( #171 )
2019-06-18 13:04:26 -04:00
Josh Holmer
d86bc80f43
Prepare for next release
2019-02-01 17:27:03 -05:00
Kornel
485a127cf6
Remove Mutex from evaluation loop ( #163 )
2019-02-01 17:03:25 -05:00
Kornel
dad6230cf1
Check timeout more often during compression ( #160 )
2019-02-01 16:30:47 -05:00
Kornel
33890cf0fd
Fake Rayon ( #162 )
...
Dummy implementation of Rayon's traits to avoid `#[cfg()]` and duplicated non-parallel code.
2019-01-28 13:35:42 -05:00
Kornel
0d4a9e06d6
Avoid using excessive number of threads ( #161 )
2019-01-27 04:15:41 -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
Kornel
55d85df9fc
Non-self-mutable reductions ( #154 )
...
* Move reductions to a module. Make copy instead of changing in-place.
* Alpha reductions
* Immutable color reductions
* Immutable interlace reductions
2019-01-12 05:07:57 -05:00
Josh Holmer
918c52eed8
Fix more nonstandard sBIT headers
...
Closes #153
2018-12-02 00:13:30 -05:00
Joshua Holmer
1305b5cf17
Fix clippy lints and run rustfmt
2018-11-26 13:41:14 -05:00
Joshua Holmer
041c433ccb
Handle non-standard sBIT headers
...
Closes #141
2018-11-26 13:10:21 -05:00
Kornel
ff7a9547c3
Nicer wrapper for cfzlib ( #149 )
2018-11-25 03:29:30 -05:00
Kornel
602cd6991e
80× faster palette reduction ( #150 )
...
* Faster palette reduction
* Simplified iterator
* Mutable scanline iterator
2018-11-25 01:31:43 -05:00
Kornel
686adcdebd
Optimize RGB/A to palette conversion ( #148 )
2018-11-22 21:52:02 -05:00
Kornel
588d5bd52b
Tweaks and Microoptimizations ( #146 )
...
* Fixed alpha benchmark
* Dedupe function
* Use integer math when rounding
* Fewer temporaries when slicing palette
* Filtering microoptimizations
2018-11-20 08:39:46 -05:00
Kornel
4765eaa7f3
Alpha heuristic improvements ( #144 )
...
* Compress alpha with strategy sensitive to repetitions
* Update reductions flag when alpha changed
* Avoid needlessly cloning out-of-date idat_data and temp raw_data
2018-11-14 08:30:15 -05:00
Kornel
96eda85806
Identify and drop useless sRGB profiles ( #143 )
2018-11-13 14:37:02 -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
903f962f29
Version 2.1.4
2018-09-28 21:05:58 -04:00
Josh Holmer
a4e0a34357
Bump version to 2.1.3
2018-09-16 23:21:51 -04:00
Kornel
3c466df80e
Chunk name as 4 bytes ( #135 )
2018-09-16 16:09:55 -04:00
Josh Holmer
edd4966cea
Fix compilation error on i686 due to cfzlib incompat ( #138 )
...
Closes #137
2018-09-16 14:43:08 -04:00
Kornel
72393d06c9
Parallel loading ( #136 )
...
* Parallel loading
* Avoid vec allocation per pixel
2018-09-15 17:30:53 -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
7895e42687
Version 2.1.1
2018-08-11 20:34:04 -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
3b42f42491
Revert "Revert "Make cfzlib the default on platforms that support it""
...
This reverts commit ff0e3df948 .
2018-08-04 23:08:30 -04:00
Kornel
1322416ba4
Cleanup on error ( #132 )
...
Closes #126
2018-08-04 23:02:56 -04:00
Matthias Krüger
947ccaad04
fix more clippy warnings found by "cargo clippy --all-targets --all-features" ( #130 )
2018-08-02 23:19:42 -04:00
Josh Holmer
f862a0df24
Apply clippy fixes
2018-07-28 16:51:54 -04:00
Matthias Krüger
868fd502b9
reduce_alpha_to_up(): simplify code, don't convert Vec -> iter -> Vec in order to reverse elts, just vec.reverse(). ( #127 )
2018-07-28 11:19:56 -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
ff0e3df948
Revert "Make cfzlib the default on platforms that support it"
...
This reverts commit 2702145f3f .
cfzlib seems to have a MASSIVE memory leak in it. Trying to use it
when processing many files at once will cause your system to run out
of memory.
Closes #125
2018-07-21 00:37:57 -04:00
Josh Holmer
d110949d2a
Version 2.0.0
2018-07-20 19:19:20 -04:00
Josh Holmer
2702145f3f
Make cfzlib the default on platforms that support it
...
Raises the minimum Rust version to 1.27.0
2018-07-20 19:03:17 -04:00
Josh Holmer
b235e5601f
Remove deprecated clippy plugin, use rustup clippy now
2018-07-20 18:50:27 -04:00
Kornel
76a2e51c15
Reduce allocations ( #122 )
...
* Iterate with fewer temp allocations
* Avoid allocation when not reducing
* Avoid slow modulo
2018-07-20 18:40:51 -04:00
Kornel
c530bba261
--keep option ( #121 )
2018-07-17 23:55:21 -04:00
Kornel
c99b3778b2
Expose only one internal module specifically for tests ( #123 )
...
Closes #98
2018-07-17 23:38:11 -04:00
Kornel
efde5747c4
Parse without temporary allocation ( #119 )
2018-07-15 09:11:26 -04:00
Josh Holmer
ebd94934a5
Make PngError non-exhaustive for forward compatibility
2018-07-14 15:45:25 -04:00
Kornel
e1cf3bf54b
Display options together, in source order ( #120 )
2018-07-14 15:28:47 -04:00
Kornel
cb52d8466a
Reading from stdin ( #118 )
2018-07-12 07:54:06 -04:00
Kornel
24735b6ab3
Option to limit wall clock time spent on optimization trials ( #115 )
2018-07-12 07:40:11 -04:00
Kornel
d2b1d56e8b
Improved limiting of max gzip size ( #116 )
2018-07-10 22:36:43 -04:00
Kornel
67fd229f20
CLI args value names ( #114 )
2018-07-10 18:42:55 -04:00
Kornel
55a095d536
Enum for stdout writing flag ( #110 )
2018-07-10 18:41:06 -04:00
myfreeweb
ae65e4be8d
Make Rayon an optional dependency ( #112 )
...
On WebAssembly, Rayon does not work (thread pool fails to initialize since threads are stubbed out).
2018-07-06 10:50:36 -04:00
Kornel
2d303f5dc2
Avoid double glob processing on unix ( #111 )
2018-07-06 08:11:42 -04:00
Kornel
442eaf766c
Bail early ( #104 )
2018-06-08 00:09:22 -04:00
Kornel
3e5b61e0c8
Compare images without allocating memory ( #107 )
2018-06-06 21:59:43 -04:00
magicgoose
5570a24781
allow listing more than 2 filters ( #105 )
...
Closes #101
2018-06-06 21:10:20 -04:00
Kornel
e472c82876
Option to use Cloudflare's zlib for compression ( #103 )
...
Behind the nightly feature flag for now--stable ASM is coming in Rust 1.27
2018-06-04 15:39:51 -04:00
Josh Holmer
d7369707ba
Fix a change that breaks itertools with newer versions of Rust nightly
2018-03-04 23:47:06 -05:00
Josh Stone
6f123c6382
Update to rayon 1.0
2018-02-20 14:14:45 -08:00
Josh Holmer
3d643b16b2
Adjust spacing in help command
2018-01-31 14:10:03 -05:00
Josh Holmer
d614bba3ac
Adjust command line presets to take advantage of the 50% speedup gained by removing memory options
2018-01-31 14:07:03 -05:00
Josh Holmer
66c1662537
Remove unused libc dependency
2018-01-30 23:54:30 -05:00
Josh Holmer
fe9cd01b82
Replace miniz_sys with miniz_oxide, a Rust implementation of miniz
...
This also improves decompression performance by 15%, and obsoletes the
`--zm` parameter.
Closes #57
2018-01-30 23:52:37 -05:00
Josh Holmer
0c2e3777b1
Refactor an if statement
2018-01-30 22:27:34 -05:00
Josh Holmer
348c7dbc56
Extract a function into a submodule
2018-01-30 22:21:31 -05:00
Josh Holmer
3497040b78
Remove useless annotation
2018-01-30 22:18:22 -05:00
Josh Holmer
cf5b90b444
Preallocate vector on reading in file
...
Provides 1.5% overall speedup on -o4
2018-01-30 22:15:03 -05:00
Josh Holmer
eb739c9ff9
Implement unix-specific permissions copying
...
Closes #4
2018-01-30 10:13:29 -05:00
Josh Holmer
ece85e6d15
Refactoring of internal code into smaller chunks.
...
There is still more to be done.
2018-01-30 09:35:03 -05:00
Josh Holmer
aa8b58628e
Fix spacing of line breaks in the rendered documentation
...
Closes #94
2018-01-18 17:30:51 -05: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
d204427f73
Refactor options presets
2018-01-10 11:22:52 -05:00
Josh Holmer
88f5bb0931
Hide modules from documentation, and only export structs used in options or return types
2018-01-10 10:37:01 -05:00
Josh Holmer
fe9fd95b21
Update some old documentation
2018-01-10 10:26:12 -05:00
Josh Holmer
32e3d245f9
Run latest rustfmt
2017-12-27 17:21:21 -05:00
Josh Holmer
bb6a2513eb
Return exit code of 1 if error occurs while processing a file using the CLI
...
Closes #93
2017-12-27 17:20:12 -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
9c7fdfd9d1
Fix parsing of glob paths on Windows
...
Closes #90
2017-11-06 19:01:18 -05:00
Josh Holmer
fa334e0750
Update dependencies
2017-11-06 18:50:10 -05:00
Emiel Beinema
b417e2bde7
Return an error when an APNG header is encountered
2017-09-30 23:50:52 +02:00
Emiel Beinema
4711cd6620
Check header of file before loading it in memory
2017-09-27 14:22:33 +02: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
Josh Holmer
e3a26b77a4
Fix a bug in reducing palettes with a bit depth of two
...
Closes #80
2017-09-10 23:26:39 -04:00
Josh Holmer
0db03c6faf
Fix new clippy lints
2017-09-03 23:36:38 -04:00
Josh Holmer
ec65bf7676
Code cleanup
2017-07-26 07:57:13 -04:00
Josh Holmer
f41ef551d3
Enable option for multiple alpha transformations
2017-07-26 00:37:55 -04:00
Josh Holmer
413f1aac7c
Automatically change transparent pixels to black
2017-07-24 08:47:27 -04:00
Josh Holmer
19405cabd6
Fix help text
...
Closes #70
2017-07-01 10:10:26 -04:00
SethDusek
cf3789564e
Make error module public
2017-06-19 07:21:43 +05:00
Josh Holmer
5f4ddbb8f4
Upgrade dependencies
2017-06-14 18:28:07 -04:00
Josh Holmer
ed3b843dd2
Update rayon and itertools dependencies
2017-05-02 19:29:20 -04:00
Josh Holmer
84cf6b09c2
Run rustfmt since it updated to v0.8.0.
...
I don't really like the new changes, but we might as well follow along.
2017-03-08 11:14:33 -05:00
Josh Holmer
d18850ebab
Ignore color reductions that would increase file size
...
Closes #61
2017-03-08 10:11:13 -05:00
Josh Holmer
6499933eab
Don't write larger file if moving from interlaced to non-interlaced
...
Closes #62
2017-03-07 09:58:23 -05:00
Josh Holmer
848a73723e
Minor changes from last commit
2017-03-06 22:20:11 -05:00
Josh Holmer
6c8e7d253d
Verify images are correct before outputting them, and fix a bug in certain images
...
Closes #60
2017-03-06 20:16:28 -05:00
Josh Holmer
c79ba3ab8a
Version 0.14.4
2017-02-26 22:53:23 -05:00
Josh Holmer
87810829ce
Fix issues in transparency palette reduction and release version 0.14.3
2017-02-25 23:33:55 -05:00
Josh Holmer
44818a854b
Fix two bugs in reducing palette and release version 0.14.2
2017-02-22 15:45:46 -05:00
Joshua Holmer
8e02aa8294
Remove zlib dependency, which broke with the new version of zlib
2017-02-21 21:45:53 -05:00
Josh Holmer
705d280f8b
Fix warning when clippy not enabled
2017-02-19 10:43:46 -05:00
Josh Holmer
ce2d166de2
Allow cyclomatic complexity on parse_opts function, there's no reasonable way to split this up
...
Closes #26
2017-02-15 13:01:17 -05:00
Josh Holmer
8116d69c3c
Minor optimizations
2017-01-10 08:11:10 -05:00
Josh Holmer
f4b643d54b
Fix clippy lints, now that clippy is working again. Hooray!
2016-12-16 21:24:47 -05:00
Josh Holmer
7261fa3398
Release 0.13.0
2016-12-12 13:54:18 -05:00
Josh Holmer
2810316f4e
Reduce certain headers when reducing color type
...
Fixes #52
2016-12-12 09:57:18 -05:00
Josh Holmer
33f1fad711
Minor refactoring
2016-12-03 15:18:11 -05:00
Joshua Holmer
bf341dd20f
Fix clippy warnings
2016-12-01 22:33:38 -05:00
Josh Holmer
6d49d7b8f9
Implement zopfli compression, available as a CLI flag (-Z)
...
Improves compression by about 10% over DEFLATE, but takes a very long
time at the moment, so it is off by default.
2016-12-01 12:51:30 -05:00
Alice Atlas
7460ffac73
Fix for passing in filenames that contain commas
...
The versions of clap supported by oxipng default to allowing commas to be used as a delimiter for passing a series of values in a single physical command line argument, when parsing for a parameter that accepts multiple values. This prevents oxipng from accepting filenames containing commas (it splits them into segments separated by commas and treats each one as a separate path to a file to process, generally not finding any); this patch fixes this by disabling the delimiter behavior for the 'files' argument.
2016-09-19 18:13:24 -04:00
Josh Holmer
4977dd0948
Replace current Mutex-based threading with Rayon
2016-09-17 18:16:26 -04:00
Josh Holmer
f654cbeac4
Various minor changes
2016-09-09 21:55:47 -04:00
Josh Holmer
4da65aef3f
Add clone derive for PngError
2016-09-09 08:05:24 -04:00
Josh Holmer
e0dfbf3533
Enable clippy with dev feature, and fix several clippy lints
2016-08-20 20:47:26 -04:00
Josh Holmer
dbc3d97513
Eliminate many clones
2016-08-19 23:42:04 -04:00
Josh Holmer
d99db3ad23
Convert results to return a PngError
...
Closes #44
2016-08-16 12:38:09 -04:00
Josh Holmer
3166285150
Allow using optimization presets from crate
...
Closes #43
2016-08-14 11:31:46 -04:00
Josh Holmer
58a36902f6
Fix tests
2016-08-03 08:27:45 -04:00
Josh Holmer
37c32b80ef
Remove quickcheck, as it breaks tests against 1.6.0
2016-08-03 08:15:01 -04:00
Josh Holmer
64edc9110e
Start using quickcheck and add inline hints
2016-07-30 23:14:36 -04:00
Josh Holmer
99da13bd8e
Version 0.10.0 [ci skip]
2016-07-26 12:59:28 -04:00
Josh Holmer
fa2b5c4ae5
Remove conversion from palette to grayscale
...
Closes #45
2016-07-26 12:32:43 -04:00
Josh Holmer
29557a18e8
Version 0.9.0
2016-07-14 20:00:59 -04:00