Predicting Thumbnail Sizes from PIL

Fuzzyman fuzzyman at gmail.com
Sun Sep 11 15:39:32 EDT 2005


Fredrik Lundh wrote:
[snip..]
>
> the algorithm is:
>
>     x, y = im.size
>     if x > size[0]: y = max(y * size[0] / x, 1); x = size[0]
>     if y > size[1]: x = max(x * size[1] / y, 1); y = size[1]
>     size = x, y
>
> that is, it shrinks the image horizontally first, and it then shrinks the
> resulting image vertically:
>
>     >>> 816 * 697 / 800
>     710
>     >>> 697 * 697 / 710
>     684
>

Thanks ! This was also helpful to me.

Fuzzyman
http://www.voidspace.org.uk/python

> </F>




More information about the Python-list mailing list