google.appengine.api.images package

Submodules

Module contents

Image manipulation API.

Classes defined in this module:
Image: class used to encapsulate image information and transformations for

that image.

The current manipulations that are available are resize, rotate, horizontal_flip, vertical_flip, crop and im_feeling_lucky.

It should be noted that each transform can only be called once per image per execute_transforms() call.

exception google.appengine.api.images.AccessDeniedError[source]

Bases: google.appengine.api.images.Error

The application does not have permission to access the image.

exception google.appengine.api.images.BadImageError[source]

Bases: google.appengine.api.images.Error

The image data given is corrupt.

exception google.appengine.api.images.BadRequestError[source]

Bases: google.appengine.api.images.Error

The parameters given had something wrong with them.

exception google.appengine.api.images.BlobKeyRequiredError[source]

Bases: google.appengine.api.images.Error

A blobkey is required for this operation.

exception google.appengine.api.images.Error[source]

Bases: exceptions.Exception

Base error class for this module.

class google.appengine.api.images.Image(image_data=None, blob_key=None, filename=None)[source]

Bases: object

Image object to manipulate.

static CheckValidIntParameter(parameter, min_value, max_value, name)[source]

Checks that a parameters is an integer within the specified range.

crop(left_x, top_y, right_x, bottom_y)[source]

Crop the image.

The four arguments are the scaling numbers to describe the bounding box which will crop the image. The upper left point of the bounding box will be at (left_x*image_width, top_y*image_height) the lower right point will be at (right_x*image_width, bottom_y*image_height).

Args:
left_x: float value between 0.0 and 1.0 (inclusive). top_y: float value between 0.0 and 1.0 (inclusive). right_x: float value between 0.0 and 1.0 (inclusive). bottom_y: float value between 0.0 and 1.0 (inclusive).
Raises:

TypeError if the args are not of type ‘float’. BadRequestError when there is something wrong with the given bounding box

or if MAX_TRANSFORMS_PER_REQUEST transforms have already been requested for this image.
execute_transforms(output_encoding=0, quality=None, parse_source_metadata=False, transparent_substitution_rgb=None, rpc=None)[source]

Perform transformations on a given image.

Args:

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 for JPEG & WEBP quality control.
parse_source_metadata: when True the metadata (EXIF) of the source image
is parsed before any transformations. The results can be retrieved via Image.get_original_metadata.
transparent_substition_rgb: When transparent pixels are not support in the
destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.

rpc: A UserRPC object.

Returns:
str, image data after the transformations have been performed on it.
Raises:
BadRequestError when there is something wrong with the request
specifications.

NotImageError when the image data given is not an image. BadImageError when the image data given is corrupt. LargeImageError when the image data given is too large to process. InvalidBlobKeyError when the blob key provided is invalid. TransformtionError when something errors during image manipulation. AccessDeniedError: when the blobkey refers to a Google Storage object, and

the application does not have permission to access the object.
ObjectNotFoundError:: when the blobkey refers to an object that no longer
exists.

Error when something unknown, but bad, happens.

execute_transforms_async(output_encoding=0, quality=None, parse_source_metadata=False, transparent_substitution_rgb=None, rpc=None)[source]

Perform transformations on a given image - async version.

Args:

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 for JPEG & WEBP quality control.
parse_source_metadata: when True the metadata (EXIF) of the source image
is parsed before any transformations. The results can be retrieved via Image.get_original_metadata.
transparent_substition_rgb: When transparent pixels are not support in the
destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.

rpc: A UserRPC object.

Returns:
A UserRPC object.
Raises:
BadRequestError when there is something wrong with the request
specifications.

NotImageError when the image data given is not an image. BadImageError when the image data given is corrupt. LargeImageError when the image data given is too large to process. InvalidBlobKeyError when the blob key provided is invalid. TransformtionError when something errors during image manipulation. AccessDeniedError: when the blobkey refers to a Google Storage object, and

the application does not have permission to access the object.

ValueError: when transparent_substitution_rgb is not an integer Error when something unknown, but bad, happens.

format

Gets the format of the image.

get_original_metadata()[source]

Metadata of the original image.

Returns a dictionary of metadata extracted from the original image during execute_transform. Note, that some of the EXIF fields are processed, e.g., fields with multiple values returned as lists, rational types are returned as floats, GPS coordinates already parsed to signed floats, etc. ImageWidth and ImageLength fields are corrected if they did not correspond to the actual dimensions of the original image.

Returns:
dict with string keys. If execute_transform was called with parse_metadata being True, this dictionary contains information about various properties of the original image, such as dimensions, color profile, and properties from EXIF. Even if parse_metadata was False or the images did not have any metadata, the dictionary will contain a limited set of metadata, at least ‘ImageWidth’ and ‘ImageLength’, corresponding to the dimensions of the original image. It will return None, if it is called before a successful execute_transfrom.
height

Gets the height of the image.

histogram(rpc=None)[source]

Calculates the histogram of the image.

Args:
rpc: A UserRPC object.

Returns: 3 256-element lists containing the number of occurences of each value of each color in the order RGB. As described at http://en.wikipedia.org/wiki/Color_histogram for N = 256. i.e. the first value of the first list contains the number of pixels with a red value of 0, the second the number with a red value of 1.

Raises:
NotImageError when the image data given is not an image. BadImageError when the image data given is corrupt. LargeImageError when the image data given is too large to process. Error when something unknown, but bad, happens.
histogram_async(rpc=None)[source]

Calculates the histogram of the image - async version.

Args:
rpc: An optional UserRPC object.
Returns:
rpc: A UserRPC object.
Raises:
NotImageError when the image data given is not an image. BadImageError when the image data given is corrupt. LargeImageError when the image data given is too large to process. Error when something unknown, but bad, happens.
horizontal_flip()[source]

Flip the image horizontally.

Raises:
BadRequestError if MAX_TRANSFORMS_PER_REQUEST transforms have already been requested on the image.
im_feeling_lucky()[source]

Automatically adjust image contrast and color levels.

This is similar to the “I’m Feeling Lucky” button in Picasa.

Raises:
BadRequestError if MAX_TRANSFORMS_PER_REQUEST transforms have already
been requested for this image.
resize(width=0, height=0, crop_to_fit=False, crop_offset_x=0.5, crop_offset_y=0.5, allow_stretch=False)[source]

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.
rotate(degrees)[source]

Rotate an image a given number of degrees clockwise.

Args:
degrees: int, must be a multiple of 90.
Raises:
TypeError when degrees is not either ‘int’ or ‘long’ types. BadRequestError when there is something wrong with the given degrees or if MAX_TRANSFORMS_PER_REQUEST transforms have already been requested.
set_correct_orientation(correct_orientation)[source]

Set flag to correct image orientation based on image metadata.

EXIF metadata within the image may contain a parameter indicating its proper orientation. This value can equal 1 through 8, inclusive. “1” means that the image is in its “normal” orientation, i.e., it should be viewed as it is stored. Normally, this “orientation” value has no effect on the behavior of the transformations. However, calling this function with the value CORRECT_ORIENTATION any orientation specified in the EXIF metadata will be corrected during the first transformation.

NOTE: If CORRECT_ORIENTATION is specified but the image is already in portrait orientation, i.e., “taller” than it is “wide” no corrections will be made, since it appears that the camera has already corrected it.

Regardless whether the correction was requested or not, the orientation value in the transformed image is always cleared to indicate that no additional corrections of the returned image’s orientation is necessary.

Args:
correct_orientation: a value from ORIENTATION_CORRECTION_TYPE.
Raises:
BadRequestError if correct_orientation value is invalid.
vertical_flip()[source]

Flip the image vertically.

Raises:
BadRequestError if MAX_TRANSFORMS_PER_REQUEST transforms have already been requested on the image.
width

Gets the width of the image.

exception google.appengine.api.images.InvalidBlobKeyError(blob_key=None)[source]

Bases: google.appengine.api.images.Error

The provided blob key was invalid.

exception google.appengine.api.images.LargeImageError[source]

Bases: google.appengine.api.images.Error

The image data given is too large to process.

exception google.appengine.api.images.NotImageError[source]

Bases: google.appengine.api.images.Error

The image data given is not recognizable as an image.

exception google.appengine.api.images.ObjectNotFoundError[source]

Bases: google.appengine.api.images.Error

The object referred to by a BlobKey does not exist.

exception google.appengine.api.images.TransformationError[source]

Bases: google.appengine.api.images.Error

Error while attempting to transform the image.

exception google.appengine.api.images.UnsupportedSizeError[source]

Bases: google.appengine.api.images.Error

Specified size is not supported by requested operation.

google.appengine.api.images.composite(inputs, width, height, color=0, output_encoding=0, quality=None, rpc=None)[source]

Composite one or more images onto a canvas - async version.

Args:

inputs: a list of tuples (image_data, x_offset, y_offset, opacity, anchor) where

image_data: str, source image data. x_offset: x offset in pixels from the anchor position y_offset: y offset in piyels from the anchor position opacity: opacity of the image specified as a float in range [0.0, 1.0] anchor: anchoring point from ANCHOR_POINTS. The anchor point of the image is aligned with the same anchor point of the canvas. e.g. TOP_RIGHT would place the top right corner of the image at the top right corner of the canvas then apply the x and y offsets.

width: canvas width in pixels. height: canvas height in pixels. color: canvas background color encoded as a 32 bit unsigned int where each

color channel is represented by one byte in order ARGB.

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 for JPEG quality control.

rpc: Optional UserRPC object.

Returns:
str, image data of the composited image.
Raises:
TypeError If width, height, color, x_offset or y_offset are not of type int or long or if opacity is not a float BadRequestError If more than MAX_TRANSFORMS_PER_REQUEST compositions have been requested, if the canvas width or height is greater than 4000 or less than or equal to 0, if the color is invalid or if for any composition option, the opacity is outside the range [0,1] or the anchor is invalid.
google.appengine.api.images.composite_async(inputs, width, height, color=0, output_encoding=0, quality=None, rpc=None)[source]

Composite one or more images onto a canvas - async version.

Args:

inputs: a list of tuples (image_data, x_offset, y_offset, opacity, anchor) where

image_data: str, source image data. x_offset: x offset in pixels from the anchor position y_offset: y offset in piyels from the anchor position opacity: opacity of the image specified as a float in range [0.0, 1.0] anchor: anchoring point from ANCHOR_POINTS. The anchor point of the image is aligned with the same anchor point of the canvas. e.g. TOP_RIGHT would place the top right corner of the image at the top right corner of the canvas then apply the x and y offsets.

width: canvas width in pixels. height: canvas height in pixels. color: canvas background color encoded as a 32 bit unsigned int where each

color channel is represented by one byte in order ARGB.

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 for JPEG quality control.

rpc: Optional UserRPC object.

Returns:
A UserRPC object.
Raises:
TypeError If width, height, color, x_offset or y_offset are not of type int or long or if opacity is not a float BadRequestError If more than MAX_TRANSFORMS_PER_REQUEST compositions have been requested, if the canvas width or height is greater than 4000 or less than or equal to 0, if the color is invalid or if for any composition option, the opacity is outside the range [0,1] or the anchor is invalid.
google.appengine.api.images.create_rpc(deadline=None, callback=None)[source]

Creates an RPC object for use with the images API.

Args:
deadline: Optional deadline in seconds for the operation; the default
is a system-specific deadline (typically 5 seconds).

callback: Optional callable to invoke on completion.

Returns:
An apiproxy_stub_map.UserRPC object specialized for this service.
google.appengine.api.images.crop(image_data, left_x, top_y, right_x, bottom_y, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Crop the given image.

The four arguments are the scaling numbers to describe the bounding box which will crop the image. The upper left point of the bounding box will be at (left_x*image_width, top_y*image_height) the lower right point will be at (right_x*image_width, bottom_y*image_height).

Args:

image_data: str, source image data. left_x: float value between 0.0 and 1.0 (inclusive). top_y: float value between 0.0 and 1.0 (inclusive). right_x: float value between 0.0 and 1.0 (inclusive). bottom_y: float value between 0.0 and 1.0 (inclusive). 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: A User RPC Object transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Raises:

TypeError if the args are not of type ‘float’. BadRequestError when there is something wrong with the given bounding box. Error when something went wrong with the call. See Image.ExecuteTransforms

for more details.
google.appengine.api.images.crop_async(image_data, left_x, top_y, right_x, bottom_y, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Crop the given image - async version.

The four arguments are the scaling numbers to describe the bounding box which will crop the image. The upper left point of the bounding box will be at (left_x*image_width, top_y*image_height) the lower right point will be at (right_x*image_width, bottom_y*image_height).

Args:

image_data: str, source image data. left_x: float value between 0.0 and 1.0 (inclusive). top_y: float value between 0.0 and 1.0 (inclusive). right_x: float value between 0.0 and 1.0 (inclusive). bottom_y: float value between 0.0 and 1.0 (inclusive). 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: An optional UserRPC object. transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Returns:
A UserRPC object, call get_result to complete the RPC and obtain the crop
result.
Raises:

TypeError if the args are not of type ‘float’. BadRequestError when there is something wrong with the given bounding box. Error when something went wrong with the call. See Image.ExecuteTransforms

for more details.
google.appengine.api.images.delete_serving_url(blob_key, rpc=None)[source]

Delete a serving url that was created for a blob_key using get_serving_url.

Args:
blob_key: BlobKey, BlobInfo, str, or unicode representation of BlobKey of
blob that has an existing URL to delete.

rpc: Optional UserRPC object.

Raises:
BlobKeyRequiredError: when no blobkey was specified. InvalidBlobKeyError: the blob_key supplied was invalid. Error: There was a generic error deleting the serving url.
google.appengine.api.images.delete_serving_url_async(blob_key, rpc=None)[source]

Delete a serving url created using get_serving_url - async version.

Args:
blob_key: BlobKey, BlobInfo, str, or unicode representation of BlobKey of
blob that has an existing URL to delete.

rpc: Optional UserRPC object.

Returns:
A UserRPC object.
Raises:
BlobKeyRequiredError: when no blobkey was specified. InvalidBlobKeyError: the blob_key supplied was invalid. Error: There was a generic error deleting the serving url.
google.appengine.api.images.get_serving_url(blob_key, size=None, crop=False, secure_url=None, filename=None, rpc=None)[source]

Obtain a url that will serve the underlying image.

This URL is served by a high-performance dynamic image serving infrastructure. This URL format also allows dynamic resizing and crop with certain restrictions. To get dynamic resizing and cropping, specify size and crop arguments, or simply append options to the end of the default url obtained via this call. Here is an example:

get_serving_url -> “http://lh3.ggpht.com/SomeCharactersGoesHere

To get a 32 pixel sized version (aspect-ratio preserved) simply append “=s32” to the url:

http://lh3.ggpht.com/SomeCharactersGoesHere=s32

To get a 32 pixel cropped version simply append “=s32-c”:

http://lh3.ggpht.com/SomeCharactersGoesHere=s32-c

Available sizes are any integer in the range [0, 1600] and is available as IMG_SERVING_SIZES_LIMIT.

Args:
blob_key: BlobKey, BlobInfo, str, or unicode representation of BlobKey of
blob to get URL of.

size: int, size of resulting images crop: bool, True requests a cropped image, False a resized one. secure_url: bool, True requests a https url, False requests a http url. filename: The filename of a Google Storage object to get the URL of. rpc: Optional UserRPC object.

Returns:
str, a url
Raises:

BlobKeyRequiredError: when no blobkey was specified in the ctor. UnsupportedSizeError: when size parameters uses unsupported sizes. BadRequestError: when crop/size are present in wrong combination, or a

blob_key and a filename have been specified.

TypeError: when secure_url is not a boolean type. AccessDeniedError: when the blobkey refers to a Google Storage object, and

the application does not have permission to access the object.
ObjectNotFoundError:: when the blobkey refers to an object that no longer
exists.
google.appengine.api.images.get_serving_url_async(blob_key, size=None, crop=False, secure_url=None, filename=None, rpc=None)[source]

Obtain a url that will serve the underlying image - async version.

This URL is served by a high-performance dynamic image serving infrastructure. This URL format also allows dynamic resizing and crop with certain restrictions. To get dynamic resizing and cropping, specify size and crop arguments, or simply append options to the end of the default url obtained via this call. Here is an example:

get_serving_url -> “http://lh3.ggpht.com/SomeCharactersGoesHere

To get a 32 pixel sized version (aspect-ratio preserved) simply append “=s32” to the url:

http://lh3.ggpht.com/SomeCharactersGoesHere=s32

To get a 32 pixel cropped version simply append “=s32-c”:

http://lh3.ggpht.com/SomeCharactersGoesHere=s32-c

Available sizes are any integer in the range [0, 1600] and is available as IMG_SERVING_SIZES_LIMIT.

Args:
blob_key: BlobKey, BlobInfo, str, or unicode representation of BlobKey of
blob to get URL of.

size: int, size of resulting images crop: bool, True requests a cropped image, False a resized one. secure_url: bool, True requests a https url, False requests a http url. filename: The filename of a Google Storage object to get the URL of. rpc: Optional UserRPC object.

Returns:
A UserRPC whose result will be a string that is the serving url
Raises:

BlobKeyRequiredError: when no blobkey was specified in the ctor. UnsupportedSizeError: when size parameters uses unsupported sizes. BadRequestError: when crop/size are present in wrong combination, or a

blob_key and a filename have been specified.

TypeError: when secure_url is not a boolean type. AccessDeniedError: when the blobkey refers to a Google Storage object, and

the application does not have permission to access the object.
google.appengine.api.images.histogram(image_data, rpc=None)[source]

Calculates the histogram of the given image.

Args:
image_data: str, source image data. rpc: An optional UserRPC object.

Returns: 3 256-element lists containing the number of occurences of each value of each color in the order RGB.

Raises:
NotImageError when the image data given is not an image. BadImageError when the image data given is corrupt. LargeImageError when the image data given is too large to process. Error when something unknown, but bad, happens.
google.appengine.api.images.histogram_async(image_data, rpc=None)[source]

Calculates the histogram of the given image - async version.

Args:
image_data: str, source image data. rpc: An optional UserRPC object.
Returns:
An UserRPC object.
Raises:
NotImageError when the image data given is not an image. BadImageError when the image data given is corrupt. LargeImageError when the image data given is too large to process. Error when something unknown, but bad, happens.
google.appengine.api.images.horizontal_flip(image_data, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Flip the image horizontally.

Args:

image_data: str, source image data. 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: An Optional UserRPC object transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Raises:
Error when something went wrong with the call. See Image.ExecuteTransforms
for more details.
google.appengine.api.images.horizontal_flip_async(image_data, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Flip the image horizontally - async version.

Args:

image_data: str, source image data. 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: An Optional UserRPC object transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Returns:
A UserRPC object, call get_result to complete the RPC and obtain the crop
result.
Raises:
Error when something went wrong with the call. See Image.ExecuteTransforms
for more details.
google.appengine.api.images.im_feeling_lucky(image_data, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Automatically adjust image levels.

This is similar to the “I’m Feeling Lucky” button in Picasa.

Args:

image_data: str, source image data. 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: An optional UserRPC object. transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Raises:
Error when something went wrong with the call. See Image.ExecuteTransforms
for more details.
google.appengine.api.images.im_feeling_lucky_async(image_data, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Automatically adjust image levels - async version.

This is similar to the “I’m Feeling Lucky” button in Picasa.

Args:

image_data: str, source image data. 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: An optional UserRPC object. transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Returns:
A UserRPC object.
Raises:
Error when something went wrong with the call. See Image.ExecuteTransforms
for more details.
google.appengine.api.images.resize(image_data, width=0, height=0, output_encoding=0, quality=None, correct_orientation=0, crop_to_fit=False, crop_offset_x=0.5, crop_offset_y=0.5, allow_stretch=False, rpc=None, transparent_substitution_rgb=None)[source]

Resize a given image file 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:

image_data: str, source image data. width: int, width (in pixels) to change the image width to. height: int, 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 for JPEG quality control.
correct_orientation: one of 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 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.

rpc: Optional UserRPC object. transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Raises:

TypeError when width or height not either ‘int’ or ‘long’ types. BadRequestError when there is something wrong with the given height or

width.
Error when something went wrong with the call. See Image.ExecuteTransforms
for more details.
google.appengine.api.images.resize_async(image_data, width=0, height=0, output_encoding=0, quality=None, correct_orientation=0, crop_to_fit=False, crop_offset_x=0.5, crop_offset_y=0.5, allow_stretch=False, rpc=None, transparent_substitution_rgb=None)[source]

Resize a given image file maintaining the aspect ratio - async version.

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:

image_data: str, source image data. width: int, width (in pixels) to change the image width to. height: int, 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 for JPEG quality control.
correct_orientation: one of 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 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.

rpc: A UserRPC object. transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Returns:
A UserRPC object, call get_result() to obtain the result of the RPC.
Raises:

TypeError when width or height not either ‘int’ or ‘long’ types. BadRequestError when there is something wrong with the given height or

width.
Error when something went wrong with the call. See Image.ExecuteTransforms
for more details.
google.appengine.api.images.rotate(image_data, degrees, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Rotate a given image a given number of degrees clockwise.

Args:

image_data: str, source image data. degrees: value from ROTATE_DEGREE_VALUES. 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: An optional UserRPC object. transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Raises:

TypeError when degrees is not either ‘int’ or ‘long’ types. BadRequestError when there is something wrong with the given degrees. Error when something went wrong with the call. See Image.ExecuteTransforms

for more details.
google.appengine.api.images.rotate_async(image_data, degrees, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Rotate a given image a given number of degrees clockwise - async version.

Args:

image_data: str, source image data. degrees: value from ROTATE_DEGREE_VALUES. 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: An optional UserRPC object. transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Returns:
A UserRPC object, call get_result to complete the RPC and obtain the crop
result.
Raises:

TypeError when degrees is not either ‘int’ or ‘long’ types. BadRequestError when there is something wrong with the given degrees. Error when something went wrong with the call. See Image.ExecuteTransforms

for more details.
google.appengine.api.images.vertical_flip(image_data, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Flip the image vertically.

Args:

image_data: str, source image data. 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: An Optional UserRPC object transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Raises:
Error when something went wrong with the call. See Image.ExecuteTransforms
for more details.
google.appengine.api.images.vertical_flip_async(image_data, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)[source]

Flip the image vertically - async version.

Args:

image_data: str, source image data. 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 for JPEG quality control.
correct_orientation: one of ORIENTATION_CORRECTION_TYPE, to indicate if
orientation correction should be performed during the transformation.

rpc: An Optional UserRPC object transparent_substition_rgb: When transparent pixels are not support in the

destination image format then transparent pixels will be substituted for the specified color, which must be 32 bit rgb format.
Returns:
A UserRPC object, call get_result to complete the RPC and obtain the crop
result.
Raises:
Error when something went wrong with the call. See Image.ExecuteTransforms
for more details.