0

Rewrote image optimisation stuff.

The old one was broken anyway.
This commit is contained in:
CounterPillow
2014-03-04 00:39:59 +01:00
parent 796481f838
commit 09477ed8a0
5 changed files with 182 additions and 41 deletions

View File

@@ -545,18 +545,92 @@ values. The valid configuration keys are listed below.
**Default:** ``95``
``optimizeimg``
.. warning::
Using image optimizers will increase render times significantly.
This option specifies which additional tools overviewer should use to
optimize the filesize of png tiles.
The tools used must be placed somewhere, where overviewer can find them, for
example the "PATH" environment variable or a directory like /usr/bin.
This should be an integer between 0 and 3.
* ``1 - Use pngcrush``
* ``2 - Use advdef``
* ``3 - Use pngcrush and advdef (Not recommended)``
Using this option may significantly increase render time, but will make
the resulting tiles smaller, with lossless image quality.
**Default:** ``0``
The option is a list of Optimizer objects, which are then executed in
the order in which they're specified::
from optimizeimages import pngnq, optipng
worlds["world"] = "/path/to/world"
renders["daytime"] = {
"world":"world",
"title":"day",
"rendermode":smooth_lighting,
"optimizeimg":[pngnq(sampling=1), optipng(olevel=3)],
}
Here is a list of supported image optimization programs:
``pngnq``
pngnq quantizes 32-bit RGBA images into 8-bit RGBA palette PNGs. This is
lossy, but reduces filesize significantly. Available settings:
``sampling``
An integer between ``1`` and ``10``, ``1`` samples all pixels, is slow and yields
the best quality. Higher values sample less of the image, which makes
the process faster, but less accurate.
**Default:** ``3``
``dither``
Either the string ``"n"`` for no dithering, or ``"f"`` for Floyd
Steinberg dithering. Dithering helps eliminate colorbanding, sometimes
increasing visual quality.
.. warning::
With pngnq version 1.0 (which is what Ubuntu 12.04 ships), the
dithering option is broken. Only the default, no dithering,
can be specified on those systems.
**Default:** ``"n"``
.. warning::
Because of several PIL bugs, only the most zoomed in level has transparency
when using pngnq. The other zoom levels have all transparency replaced by
black. This is *not* pngnq's fault, as pngnq supports multiple levels of
transparency just fine, it's PIL's fault for not even reading indexed
PNGs correctly.
``optipng``
optipng tunes the deflate algorithm and removes unneeded channels from the PNG,
producing a smaller, lossless output image. It was inspired by pngcrush.
Available settings:
``olevel``
An integer between ``0`` (few optimizations) and ``7`` (many optimizations).
The default should be satisfactory for everyone, higher levels than the default
see almost no benefit.
**Default:** ``2``
``pngcrush``
pngcrush is very slow and not very good, you should use optipng in probably all cases.
However, Overviewer still allows you to use it because we're nice people like that.
Available settings:
``brute``
Either ``True`` or ``False``. Cycles through all compression methods, and is very slow.
.. note::
There is practically no reason to ever use this. optipng will beat pngcrush, and
throwing more CPU time at pngcrush most likely won't help. If you think you need
this option, then you are most likely wrong.
**Default:** ``False``
.. note::
Don't forget to import the optimizers you use in your settings file, as shown in the
example above.
**Default:** ``[]``
``bgcolor``
This is the background color to be displayed behind the map. Its value