python-pillow/Pillow — pull request #1029 by homm (2014-11-28 02:01:50+00:00)
Title: Thumbnail tuning

There are two changes related to how `Image.thumbnail` works.

### JPEG draft decoding

`Image.thumbnail` (or more precise `Image.draft`) instructs libJPEG to open image in draft mode. I don't know original motivation of libJPEG authors to add this mode. Looks like it gives very small performance win:

```python
In [1]: from PIL import Image

In [2]: %timeit -n 20 i = Image.open('5k.jpg'); i.decoderconfig = (1, 0); i.load()
20 loops, best of 3: 245 ms per loop

In [3]: %timeit -n 20 i = Image.open('5k.jpg'); i.decoderconfig = (1, 1); i.load()
20 loops, best of 3: 234 ms per loop
```

Also it does't affect too much most of images, **but** for some images it introduces noticeable artifacts. For example this is cropped part of normal decoded image and draft. [Source](https://cloud.githubusercontent.com/assets/128982/5222835/17c5afd6-76b8-11e4-8cd3-cf4cad69d04a.jpg).

![jeans ref](https://cloud.githubusercontent.com/assets/128982/5222849/af615f0c-76b8-11e4-9f21-d7457909f35b.png) ![jeans draft](https://cloud.githubusercontent.com/assets/128982/5222850/af8d30aa-76b8-11e4-9547-1bc886f6f54d.png)

Docstring of `Image.draft()` method says:

> Configures the image file loader so it returns a version of the image that as closely as possible matches the given mode and size.

I believe what this is exactly what this method should do. But not decrease quality of image decoding even if decoder options named the same as this method.

### Bicubic as default filter

In Pillow 2.5 default filter was changed from `NEAREST` to `ANTIALIAS`. Antialias was chosen because all other filters gave poor quality for reduction. Starting from Pillow 2.7 we can replace `ANTIALIAS` with `BICUBIC`, because bicubic is a bit faster and `ANTIALIAS` doesn't give any advantages if we first scales down image with libJPEG (which uses supersampling, not convolutions).