PIL's thumbnail function returns NoneType

Hrvoje Niksic hniksic at xemacs.org
Sun Mar 1 05:35:04 EST 2009


Mirat Can Bayrak <miratcanbayrak at gmail.com> writes:

> Can you try it? it is about me or it is a bug?

Neither.  im.thumbnail() modifies the existing image object by
converting it to a thumbnail.  In Python such methods by convention
return None.

The documentation explicitly mentions that:

    Also note that this function modifies the Image object in
    place. If you need to use the full resolution image as well, apply
    this method to a copy of the original image. This method returns
    None.

> In [4]: thm = im.thumbnail((200,200))
>
> In [5]: type(thm)
> Out[5]: <type 'NoneType'>

Instead of thm, simply keep using ihm.



More information about the Python-list mailing list