English | Site Directory

Functions

The google.appengine.api.images package provides the following functions:

resize(image_data, width=0, height=0, output_encoding=images.PNG)

Resizes an image, scaling down or up to the given width and height. The function takes the image data to resize, and returns the transformed image in the same format.

Arguments:

image_data
The image to resize, as a bytestring (str) in JPEG, PNG, GIF (including animated), BMP, TIFF, or ICO format.
width
The desired width, as a number of pixels. Must be an int or long.
height
The desired height, as a number of pixels. Must be an int or long.
output_encoding
The desired format of the transformed image. This is either images.PNG or images.JPEG. The default is images.PNG.
crop(image_data, left_x, top_y, right_x, bottom_y), output_encoding=images.PNG)

Crops an image to a given bounding box. The function takes the image data to crop, and returns the transformed image in the same format.

The left, top, right and bottom of the bounding box are specified as proportional distances. The coordinates of the bounding box are determined as left_x * width, top_y * height, right_x * width and bottom_y * height. This allows you to specify the bounding box independently of the final width and height of the image, which may change simultaneously with a resize action.

Arguments:

image_data
The image to crop, as a bytestring (str) in JPEG, PNG, GIF (including animated), BMP, TIFF, or ICO format.
left_x
The left border of the bounding box, as a proportion of the image width specified as a float value from 0.0 to 1.0 (inclusive).
top_y
The top border of the bounding box, as a proportion of the image height specified as a float value from 0.0 to 1.0 (inclusive).
right_x
The right border of the bounding box, as a proportion of the image width specified as a float value from 0.0 to 1.0 (inclusive).
bottom_y
The bottom border of the bounding box, as a proportion of the image height specified as a float value from 0.0 to 1.0 (inclusive).
output_encoding
The desired format of the transformed image. This is either images.PNG or images.JPEG. The default is images.PNG.
rotate(image_data, degrees, output_encoding=images.PNG)

Rotates an image. The amount of rotation must be a multiple of 90 degrees. The function takes the image data to rotate, and returns the transformed image in the same format.

Rotation is performed clockwise. A 90 degree turn rotates the image so that the edge that was the top becomes the right edge.

Arguments:

image_data
The image to rotate, as a bytestring (str) in JPEG, PNG, GIF (including animated), BMP, TIFF, or ICO format.
degrees
The amount to rotate the image, as a number of degrees, in multiples of 90 degrees.
output_encoding
The desired format of the transformed image. This is either images.PNG or images.JPEG. The default is images.PNG.
horizontal_flip(image_data, output_encoding=images.PNG)

Flips an image horizontally. The edge that was the left becomes the right edge, and vice versa. The function takes the image data to flip, and returns the transformed image in the same format.

Arguments:

image_data
The image to flip, as a bytestring (str) in JPEG, PNG, GIF (including animated), BMP, TIFF, or ICO format.
output_encoding
The desired format of the transformed image. This is either images.PNG or images.JPEG. The default is images.PNG.
vertical_flip(image_data, output_encoding=images.PNG)

Flips an image vertically. The edge that was the top becomes the bottom edge, and vice versa. The function takes the image data to flip, and returns the transformed image in the same format.

Arguments:

image_data
The image to flip, as a bytestring (str) in JPEG, PNG, GIF (including animated), BMP, TIFF, or ICO format.
output_encoding
The desired format of the transformed image. This is either images.PNG or images.JPEG. The default is images.PNG.
im_feeling_lucky(image_data, output_encoding=images.PNG)

Adjusts the contrast and color levels of an image according to an algorithm for improving photographs. This is similar to the "I'm Feeling Lucky" feature of Google Picasa. The function takes the image data to adjust, and returns the transformed image in the same format.

Arguments:

image_data
The image to adjust, as a bytestring (str) in JPEG, PNG, GIF (including animated), BMP, TIFF, or ICO format.
output_encoding
The desired format of the transformed image. This is either images.PNG or images.JPEG. The default is images.PNG.

Note: The im_feeling_lucky() method is no-op when used locally in the SDK as there is no equivilent method in PIL.