Notices about “Concept”

This page describes about special notices about Concept.

about “Concept” Filters

doc

https://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters

Documentation about the resampling filters is somewhat misleading, because original PIL and Pillow have different phraseology each other.

For example, in Image#resize section, original PIL says:

The filter argument can be one of NEAREST (use nearest neighbour), BILINEAR (linear interpolation in a 2x2 environment), BICUBIC (cubic spline interpolation in a 4x4 environment), or ANTIALIAS (a high-quality downsampling filter). If omitted, or if the image has mode “1” or “P”, it is set to NEAREST.

Note that the bilinear and bicubic filters in the current version of PIL are not well-suited for large downsampling ratios (e.g. when creating thumbnails). You should use ANTIALIAS unless speed is much more important than quality.

and in the case of Pillow:

An optional resampling filter. This can be one of PIL.Image.NEAREST, PIL.Image.BOX, PIL.Image.BILINEAR, PIL.Image.HAMMING, PIL.Image.BICUBIC or PIL.Image.LANCZOS. If omitted, or if the image has mode “1” or “P”, it is set PIL.Image.NEAREST.

ANTIALIAS had gone in Pillow? LANCZOS can be used only with Pillow? The answer is NO. Actually, these constants are defined as:

python-pillow/Pillow/blob/master/PIL/Image.py
NEAREST = NONE = 0
BOX = 4
BILINEAR = LINEAR = 2
HAMMING = 5
BICUBIC = CUBIC = 3
LANCZOS = ANTIALIAS = 1
svn.effbot.org/public/pil/PIL/Image.py
NONE = 0
NEAREST = 0
ANTIALIAS = 1 # 3-lobed lanczos
LINEAR = BILINEAR = 2
CUBIC = BICUBIC = 3

For now, the differences in semantics are only BOX and HAMMING. Of course you can use Image.LANCZOS symbol only if you use Pillow. If you need to run the codes for PIL and Pillow, take care of it.