PIL's thumbnail function returns NoneType
tjreedy at udel.edu
Sun Mar 1 22:47:34 CET 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
Indeed, the purpose of returning None is to remind that the method does
mutation in place.
>> In : thm = im.thumbnail((200,200))
>> In : type(thm)
>> Out: <type 'NoneType'>
> Instead of thm, simply keep using ihm.
More information about the Python-list