PIL's thumbnail function returns NoneType
Terry Reedy
tjreedy at udel.edu
Sun Mar 1 16:47:34 EST 2009
Hrvoje Niksic wrote:
> 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.
Indeed, the purpose of returning None is to remind that the method does
mutation in place.
>
>> In [4]: thm = im.thumbnail((200,200))
>>
>> In [5]: type(thm)
>> Out[5]: <type 'NoneType'>
>
> Instead of thm, simply keep using ihm.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list