'Make this image into a thumbnail.  This method modifies the
image to contain a thumbnail version of itself, no larger than
the given size.  This method calculates an appropriate thumbnail
size to preserve the aspect of the image, calls the
:py:meth:`~PIL.Image.Image.draft` method to configure the file reader
(where applicable), and finally resizes the image.
Note that this function modifies the :py:class:`~PIL.Image.Image`
object in place.  If you need to use the full resolution image as well,
apply this method to a :py:meth:`~PIL.Image.Image.copy` of the original
image.
:param size: Requested size.
:param resample: Optional resampling filter.  This can be one
of :py:attr:`PIL.Image.NEAREST`, :py:attr:`PIL.Image.BILINEAR`,
:py:attr:`PIL.Image.BICUBIC`, or :py:attr:`PIL.Image.LANCZOS`.
If omitted, it defaults to :py:attr:`PIL.Image.BICUBIC`.
(was :py:attr:`PIL.Image.NEAREST` prior to version 2.5.0)
:returns: None'

def thumbnail(self, size, resample=BICUBIC):

    (x, y) = self.size
    if (x > size[0]):
        y = int(max(((y * size[0]) / x), 1))
        x = int(size[0])
    if (y > size[1]):
        x = int(max(((x * size[1]) / y), 1))
        y = int(size[1])
    size = (x, y)
    if (size == self.size):
        return
    self.draft(None, size)
    im = self.resize(size, resample)
    self.im = im.im
    self.mode = im.mode
    self.size = size
    self.readonly = 0
    self.pyaccess = None
