Skip to content

Commit b9e894c

Browse files
committed
docs: add encode speed optimization tips [skip-ci]
1 parent 54bd4c3 commit b9e894c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/encode.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,25 @@ On success the buffer must be freed by the user.
202202
\* Option may be optimized if not set explicitly.
203203
204204
Options not listed here have no effect on encoders.
205+
206+
# Performance
207+
208+
The default encoder settings match the [reference implementation](http://libpng.org/pub/png/libpng.html)
209+
and will produce files of the exact same size, but there are settings that offer
210+
better performance for a small increase in file size. Reducing compression level (set `SPNG_IMG_COMPRESSION_LEVEL` to a value lower than `6`) will reduce encoding time for all image types.
211+
212+
* Truecolor and truecolor-alpha images - Reduce compression level (between `1` and `5`) and leave everything else on defaults,
213+
file size should not increase by more than 10% but encode up to three times faster.
214+
215+
* Indexed-color - Choose a reduced compression level (`1`-`5`), file size should stay within 5% but encode up to two times faster.
216+
217+
* Grayscale - Choose a reduced compression level (`1`-`5`), file size should stay within 5% but encode up two times faster.
218+
219+
* Grayscale-alpha images - Choose a reduced compression level (`1`-`5`), file size should stay within 5% but encode up to four times faster.
220+
221+
* Disabling filtering may further improve performance but will significantly increase file size.
222+
223+
!!! note
224+
See [encode experiments](https://github.com/libspng/spngt/blob/master/results/README.md#encode-experiments) for more details.
225+
226+
Recommendations are based on benchmarks with zlib, performance with other implementations (miniz, zlib-ng) was not measured.

0 commit comments

Comments
 (0)