Google Code offered in: 中文 - English - Português - Pусский - Español - 日本語
An instance of the Image class represents a single image to which multiple transformations can be applied. Methods on the instance set up transformations, which are executed all at once when the execute_transforms()
method is called.
Image
is provided by the google.appengine.api.images
module.
The Image class is used to encapsulate image information and transformations for that image.
After one or more transforms is called on an image object, you can execute the transforms with execute_transforms() method.
Note: Each transform is applied in the order requested and can only be called once per image per execute_transforms()
call.
An image to be transformed.
Arguments:
str
). The image data can be encoded in JPEG, PNG, GIF (including animated), BMP, TIFF, or ICO format. An Image instance has the following properties:
width
The width of the image, in pixels.
height
The height of the image, in pixels.
An Image instance has the following methods:
Resizes an image, scaling down or up to the given width and height.
Arguments:
int
or long
.int
or long
.Crops an image to a given bounding box. The method 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:
float
value from 0.0 to 1.0 (inclusive).float
value from 0.0 to 1.0 (inclusive).float
value from 0.0 to 1.0 (inclusive).float
value from 0.0 to 1.0 (inclusive).Rotates an image. The amount of rotation must be a multiple of 90 degrees.
Rotation is performed clockwise. A 90 degree turn rotates the image so that the edge that was the top becomes the right edge.
Arguments:
int
or long
.Flips an image horizontally. The edge that was the left becomes the right edge, and vice versa.
Flips an image vertically. The edge that was the top becomes the bottom edge, and vice versa.
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 method returns the transformed image in the same format.
Note: The im_feeling_lucky()
method is no-op when used locally in the SDK as there is no equivilent method in PIL.
Executes all transforms set for the Image instance by the above methods, and returns the result.
Arguments:
images.PNG
or images.JPEG
. The default is images.PNG
.The return value is the resulting image, as a bytestring encoded in the requested format.