Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products.

Python 3.10 is now available in preview.

google.appengine.api.images.resize

Resizes a given image file while 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.

image_data String of the source image data.
width Integer of the width (in pixels) to change the image width to.
height Integer of the height (in pixels) to change the image height to.
output_encoding A value from OUTPUT_ENCODING_TYPES.
quality A value between 1 and 100 to specify the quality of the encoding. This value is only used to control JPEG quality.
correct_orientation A value from ORIENTATION_CORRECTION_TYPE to indicate if orientation correction should be performed during the transformation.
crop_to_fit If True, and both width and height are specified, the image is cropped after being resized to fit the specified dimensions.
crop_offset_x Float value between 0.0 and 1.0. 0 is left and 1 is right. The default value is 0.5, or the center of image.
crop_offset_y Float value between 0.0 and 1.0. 0 is top and 1 is bottom. The default value is 0.5, or the center of image.
allow_stretch If True, and both width and height are specified, the image is stretched to fit the resized dimensions without maintaining the aspect ratio.
rpc Optional UserRPC object.
transparent_substitution_rgb When transparent pixels are not supported in the destination image format, then transparent pixels will be substituted for the specified color, which must be in 32-bit RGB format.

Raw image data of the resized image.

TypeError When width or height are not of integer or long type.
BadRequestError When the specified width or height is invalid.
Error All other errors. See Image.ExecuteTransforms for more details.