'Resize the image maintaining the aspect ratio.
If both width and height are specified, the more restricting of the two
values will be used when resizing the image. The maximum dimension allowed
for both width and height is 4000 pixels.
If both width and height are specified and crop_to_fit is True, the less
restricting of the two values will be used when resizing and the image will
be cropped to fit the specified size. In this case the center of cropping
can be adjusted  by crop_offset_x and crop_offset_y.
Args:
width: int, width (in pixels) to change the image width to.
height: int, height (in pixels) to change the image height to.
crop_to_fit: If True and both width and height are specified, the image is
cropped after resize to fit the specified dimensions.
crop_offset_x: float value between 0.0 and 1.0, 0 is left and 1 is right,
default is 0.5, the center of image.
crop_offset_y: float value between 0.0 and 1.0, 0 is top and 1 is bottom,
default is 0.5, the center of image.
allow_stretch: If True and both width and height are specified, the image
is stretched to fit the resize dimensions without maintaining the
aspect ratio.
Raises:
TypeError when width or height is not either \'int\' or \'long\' types.
BadRequestError when there is something wrong with the given height or
width or if MAX_TRANSFORMS_PER_REQUEST transforms have already been
requested on this image.'

def resize(self, width=0, height=0, crop_to_fit=False, crop_offset_x=0.5, crop_offset_y=0.5, allow_stretch=False):

    if ((not isinstance(width, (int, long))) or (not isinstance(height, (int, long)))):
        raise TypeError('Width    and    height    must    be    integers.')
    if ((width < 0) or (height < 0)):
        raise BadRequestError('Width    and    height    must    be    >=    0.')
    if ((not width) and (not height)):
        raise BadRequestError('At    least    one    of    width    or    height    must    be    >    0.')
    if ((width > 4000) or (height > 4000)):
        raise BadRequestError('Both    width    and    height    must    be    <=    4000.')
    if (not isinstance(crop_to_fit, bool)):
        raise TypeError('crop_to_fit    must    be    boolean.')
    if (crop_to_fit and (not (width and height))):
        raise BadRequestError('Both    width    and    height    must    be    >    0    when    crop_to_fit    is    specified.')
    if (not isinstance(allow_stretch, bool)):
        raise TypeError('allow_stretch    must    be    boolean.')
    if (allow_stretch and (not (width and height))):
        raise BadRequestError('Both    width    and    height    must    be    >    0    when    allow_stretch    is    specified.')
    self._validate_crop_arg(crop_offset_x, 'crop_offset_x')
    self._validate_crop_arg(crop_offset_y, 'crop_offset_y')
    self._check_transform_limits()
    transform = images_service_pb.Transform()
    transform.set_width(width)
    transform.set_height(height)
    transform.set_crop_to_fit(crop_to_fit)
    transform.set_crop_offset_x(crop_offset_x)
    transform.set_crop_offset_y(crop_offset_y)
    transform.set_allow_stretch(allow_stretch)
    self._transforms.append(transform)
