Image object to manipulate.
def google.appengine.api.images.Image.__init__ |
( |
|
self, |
|
|
|
image_data = None , |
|
|
|
blob_key = None , |
|
|
|
filename = None |
|
) |
| |
Constructor.
Only one of image_data, blob_key or filename can be specified.
Args:
image_data: str, image data in string form.
blob_key: BlobKey, BlobInfo, str, or unicode representation of BlobKey of
blob containing the image data.
filename: str, the filename of a Google Storage file containing the
image data. Must be in the format '/gs/bucket_name/object_name'.
Raises:
NotImageError if the given data is empty.
def google.appengine.api.images.Image.CheckValidIntParameter |
( |
|
parameter, |
|
|
|
min_value, |
|
|
|
max_value, |
|
|
|
name |
|
) |
| |
|
static |
Checks that a parameters is an integer within the specified range.
def google.appengine.api.images.Image.crop |
( |
|
self, |
|
|
|
left_x, |
|
|
|
top_y, |
|
|
|
right_x, |
|
|
|
bottom_y |
|
) |
| |
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.
def google.appengine.api.images.Image.execute_transforms |
( |
|
self, |
|
|
|
output_encoding = PNG , |
|
|
|
quality = None , |
|
|
|
parse_source_metadata = False , |
|
|
|
transparent_substitution_rgb = None , |
|
|
|
rpc = None |
|
) |
| |
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.
def google.appengine.api.images.Image.execute_transforms_async |
( |
|
self, |
|
|
|
output_encoding = PNG , |
|
|
|
quality = None , |
|
|
|
parse_source_metadata = False , |
|
|
|
transparent_substitution_rgb = None , |
|
|
|
rpc = None |
|
) |
| |
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.
def google.appengine.api.images.Image.format |
( |
|
self | ) |
|
Gets the format of the image.
def google.appengine.api.images.Image.get_original_metadata |
( |
|
self | ) |
|
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.
def google.appengine.api.images.Image.height |
( |
|
self | ) |
|
Gets the height of the image.
def google.appengine.api.images.Image.histogram |
( |
|
self, |
|
|
|
rpc = None |
|
) |
| |
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.
def google.appengine.api.images.Image.histogram_async |
( |
|
self, |
|
|
|
rpc = None |
|
) |
| |
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.
def google.appengine.api.images.Image.horizontal_flip |
( |
|
self | ) |
|
Flip the image horizontally.
Raises:
BadRequestError if MAX_TRANSFORMS_PER_REQUEST transforms have already been
requested on the image.
def google.appengine.api.images.Image.im_feeling_lucky |
( |
|
self | ) |
|
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.
def google.appengine.api.images.Image.resize |
( |
|
self, |
|
|
|
width = 0 , |
|
|
|
height = 0 , |
|
|
|
crop_to_fit = False , |
|
|
|
crop_offset_x = 0.5 , |
|
|
|
crop_offset_y = 0.5 , |
|
|
|
allow_stretch = False |
|
) |
| |
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 google.appengine.api.images.Image.rotate |
( |
|
self, |
|
|
|
degrees |
|
) |
| |
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.
def google.appengine.api.images.Image.set_correct_orientation |
( |
|
self, |
|
|
|
correct_orientation |
|
) |
| |
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.
def google.appengine.api.images.Image.vertical_flip |
( |
|
self | ) |
|
Flip the image vertically.
Raises:
BadRequestError if MAX_TRANSFORMS_PER_REQUEST transforms have already been
requested on the image.
def google.appengine.api.images.Image.width |
( |
|
self | ) |
|
Gets the width of the image.
The documentation for this class was generated from the following file:
- code/googleappengine-read-only/python/google/appengine/api/images/__init__.py