'Returns a resized copy of this image.
:param size: The requested size in pixels, as a 2-tuple:
(width, height).
:param resample: An optional resampling filter.  This can be
one of :py:attr:`PIL.Image.NEAREST`, :py:attr:`PIL.Image.BOX`,
:py:attr:`PIL.Image.BILINEAR`, :py:attr:`PIL.Image.HAMMING`,
:py:attr:`PIL.Image.BICUBIC` or :py:attr:`PIL.Image.LANCZOS`.
If omitted, or if the image has mode "1" or "P", it is
set :py:attr:`PIL.Image.NEAREST`.
See: :ref:`concept-filters`.
:returns: An :py:class:`~PIL.Image.Image` object.'

def resize(self, size, resample=NEAREST):

    if (resample not in (NEAREST, BILINEAR, BICUBIC, LANCZOS, BOX, HAMMING)):
        raise ValueError('unknown    resampling    filter')
    self.load()
    size = tuple(size)
    if (self.size == size):
        return self.copy()
    if (self.mode in ('1', 'P')):
        resample = NEAREST
    if (self.mode == 'LA'):
        return self.convert('La').resize(size, resample).convert('LA')
    if (self.mode == 'RGBA'):
        return self.convert('RGBa').resize(size, resample).convert('RGBA')
    return self._new(self.im.resize(size, resample))
