Skip to content

Thumbnail tuning - #1029

Merged
wiredfool merged 2 commits into
python-pillow:masterfrom
homm:thumbnail-tune
Dec 29, 2014
Merged

wiredfool merged 2 commits into
python-pillow:masterfrom
homm:thumbnail-tune

Conversation

@homm

@homm homm commented Nov 28, 2014

Copy link
Copy Markdown
Member

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:

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.

jeans ref jeans draft

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).

@homm

homm commented Dec 4, 2014

Copy link
Copy Markdown
Member Author

I'll resolve conflicts.

@homm

homm commented Dec 4, 2014

Copy link
Copy Markdown
Member Author

Done.

@homm

homm commented Dec 27, 2014

Copy link
Copy Markdown
Member Author

I'm worry about this PR. Will it be merged in 2.7? If you don't want to change thumbnail default filter, just let me know, I'll remove this part. But draft JPEG decoder mode should be definitely eliminated.

@aclark4life

Copy link
Copy Markdown
Member

@homm Do you want it merged in 2.7? Have @wiredfool and/or @hugovk reviewed?

@homm

homm commented Dec 28, 2014

Copy link
Copy Markdown
Member Author

I definitely want :)

@hugovk

hugovk commented Dec 28, 2014

Copy link
Copy Markdown
Member

Looks fine for me but I'll let @wiredfool check too.

@wiredfool

Copy link
Copy Markdown
Member

Ok, works for me.

wiredfool added a commit that referenced this pull request Dec 29, 2014
@wiredfool
wiredfool merged commit a31e340 into python-pillow:master Dec 29, 2014
This was referenced Apr 2, 2015
@homm
homm deleted the thumbnail-tune branch April 27, 2016 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants