A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/appengine/docs/legacy/standard/python/refdocs/google.appengine.api.images below:

google.appengine.api.images package | App Engine standard environment for Python 2

Skip to main content

Stay organized with collections Save and categorize content based on your preferences.

google.appengine.api.images package Summary

Image manipulation API.

App Engine provides the ability to manipulate image data using a dedicated Images service. The Images service can resize, rotate, flip, and crop images; it can composite multiple images into a single image; and it can convert image data between several formats. It can also enhance photographs using a predefined algorithm. The API can also provide information about an image, such as its format, width, height, and a histogram of color values.

Contents
exception google.appengine.api.images.Errorsource

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 parameter is an integer within the specified range.

crop(left_x, top_y, right_x, bottom_y)source

Crops the image.

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

Parameters
  • 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 arguments are not of type float.

  • BadRequestError – When the bounding box values are invalid 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

Performs transformations on a given image.

You can only execute one transformation per image per execute_transforms() call.

Parameters
  • 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 and 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_substitution_rgb – When transparent pixels are not supported in the destination image format, transparent pixels will be substituted for the specified color, which must be 32-bit RGB format.

  • rpc – A UserRPC object.

Returns

A string of the image data after the transformations have been performed on it.

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

Asynchronously performs transformations on a given image.

Parameters
  • 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_substitution_rgb – When transparent pixels are not supported in the destination image format, transparent pixels will be substituted for the specified color, which must be in 32-bit RGB format.

  • rpc – A UserRPC object.

Returns

A UserRPC object.

Raises
  • BadRequestError – When the request specifications are invalid.

  • 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.

  • TransformationError – When an error occurs during image manipulation.

  • AccessDeniedError – When the blob key 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 – All other error conditions.

format

Retrieves the format of the image.

height

Retrieves the height of the image.

histogram(rpc=None)source

Calculates the histogram of the image.

Parameters

rpc – A UserRPC object.

Returns

3 256-element lists containing the number of occurences of each value of each color in the order RGB. You can learn more about color histograms at Wikipedia.

Raises
  • NotImageError – When the image data supplied is not an image.

  • BadImageError – When the image data supplied is corrupt.

  • LargeImageError – When the image data supplied is too large to process.

  • Error – All other error conditions.

histogram_async(rpc=None)source

Asynchronously calculates the histogram of the image.

Parameters

rpc – An optional UserRPC object.

Returns

A UserRPC object.

Return type

rpc

Raises
  • NotImageError – When the image data supplied is not an image.

  • BadImageError – When the image data supplied is corrupt.

  • LargeImageError – When the image data supplied is too large to process.

  • Error – All other error conditions.

horizontal_flip()source

Flips the image horizontally.

Raises

BadRequestError – If MAX_TRANSFORMS_PER_REQUEST transforms have already been requested on the image.

im_feeling_lucky()source

Automatically adjusts the image’s 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

Resizes the image, maintaining the aspect ratio.

If both width and height are specified, the more restricting of the two values will be used when the image is resized. 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 the image is resized, 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.

Parameters
  • 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.

  • crop_to_fit – If True, and both width and height are specified, the image is cropped after it is 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 the 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 the 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 an integer or long type.

  • BadRequestError – When the height or width is invalid, or if MAX_TRANSFORMS_PER_REQUEST transforms have already been requested on this image.

rotate(degrees)source

Rotates an image a given number of degrees clockwise.

Parameters

degrees – Integer value of the number of degrees that an image must be rotated. This value must be a multiple of 90.

Raises
  • TypeError – When degrees is not an integer or long type.

  • BadRequestError – When the degrees value is invalid or if MAX_TRANSFORMS_PER_REQUEST transforms have already been requested.

set_correct_orientation(correct_orientation)source

Sets a flag to correct the image orientation based on image metadata.

EXIF metadata within the image may contain a parameter that indicates its proper orientation. This value can equal 1 through 8, inclusive. Setting the orientation to 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, if you call this function with the correct_orientation argument, 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 the camera has likely already corrected it.

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.

Parameters

correct_orientation – A value from ORIENTATION_CORRECTION_TYPE.

Raises

BadRequestError – If the correct_orientation value is invalid.

vertical_flip()source

Flips the image vertically.

Raises

BadRequestError – If MAX_TRANSFORMS_PER_REQUEST transforms have already been requested on the image.

width

Retrieves the width of the image.

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

Composites one or more images onto a canvas.

Parameters Returns

A string that contains the image data of the composited image.

Raises
google.appengine.api.images.composite_async(inputs, width, height, color=0, output_encoding=0, quality=None, rpc=None)source

Asynchronously composites one or more images onto a canvas.

Parameters Returns

A UserRPC object.

Raises
google.appengine.api.images.create_rpc(deadline=None, callback=None)source

Creates an RPC object for use with the Images API.

Parameters 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

Crops the image.

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

Parameters Returns

Raw image data of the transformed image.

Raises
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

Asynchronously crops the given image.

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

Parameters Returns

A UserRPC object; call get_result() to complete the RPC and obtain the crop result.

Raises
google.appengine.api.images.delete_serving_url(blob_key, rpc=None)source

Deletes a serving URL created for blob_key using get_serving_url.

Parameters Raises
google.appengine.api.images.delete_serving_url_async(blob_key, rpc=None)source

Deletes a serving URL created using get_serving_url - async version.

Parameters Returns

A UserRPC object.

Raises
google.appengine.api.images.get_serving_url(blob_key, size=None, crop=False, secure_url=None, filename=None, rpc=None)source

Obtains 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 cropping with certain restrictions. To dynamically resize and crop, specify size and crop arguments, or simply append options to the end of the default URL obtained via this call.

Example:

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

To get a 32-pixel-sized version (aspect-ratio preserved), append =s32 to the URL:

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

To get a 32-pixel cropped version, 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.

Parameters Returns

A URL string.

Raises
google.appengine.api.images.get_serving_url_async(blob_key, size=None, crop=False, secure_url=None, filename=None, rpc=None)source

Asynchronously obtains 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 cropping with certain restrictions. To dynamically resize and crop, specify size and crop arguments, or simply append options to the end of the default URL obtained via this call.

Example:

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

To get a 32-pixel-sized version (aspect-ratio preserved), append =s32 to the URL:

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

To get a 32-pixel cropped version, 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.

Parameters Returns

A UserRPC whose result will be a string that is the serving URL.

Raises
google.appengine.api.images.histogram(image_data, rpc=None)source

Calculates the histogram of the given image.

Parameters Returns

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

Raises
google.appengine.api.images.histogram_async(image_data, rpc=None)source

Calculates the histogram of the given image - async version.

Parameters Returns

An UserRPC object.

Raises
google.appengine.api.images.horizontal_flip(image_data, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)source

Flips the image horizontally.

Parameters Returns

Raw image data of the transformed image.

Raises

Error – All errors. 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

Asynchronously flips the image horizontally.

Parameters Returns

A UserRPC object; call get_result() to complete the RPC and obtain the crop result.

Raises

Error – All errors. 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 adjusts image levels.

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

Parameters Returns

Raw image data of the transformed image.

Raises

Error – All errors. 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

Asynchronously automatically adjusts image levels.

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

Parameters Returns

A UserRPC object.

Raises

Error – All errors. 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

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.

Parameters Returns

Raw image data of the resized image.

Raises
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

Asynchronously resizes an 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.

Parameters Returns

A UserRPC object; call get_result() to obtain the result of the RPC.

Raises
google.appengine.api.images.rotate(image_data, degrees, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)source

Rotates an image a given number of degrees clockwise.

Parameters Returns

Raw image data of the rotated image.

Raises
google.appengine.api.images.rotate_async(image_data, degrees, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)source

Asynchronously rotates an image a specified number of degrees clockwise.

Parameters Returns

A UserRPC object; call get_result() to complete the RPC and obtain the crop result.

Raises
google.appengine.api.images.vertical_flip(image_data, output_encoding=0, quality=None, correct_orientation=0, rpc=None, transparent_substitution_rgb=None)source

Flips the image vertically.

Parameters Returns

Raw image data of the transformed image.

Raises

Error – All errors. 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

Asynchronously flips the image vertically.

Parameters Returns

A UserRPC object; call get_result() to complete the RPC and obtain the crop result.

Raises

Error – All errors. See Image.ExecuteTransforms for more details.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-06-16 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["The `google.appengine.api.images` package provides an API for manipulating image data, offering features like resizing, rotating, flipping, cropping, and compositing multiple images."],["The API allows conversion between several image formats and can enhance photographs using a predefined algorithm, and retrieve information like format, width, height, and a color histogram."],["The `Image` class within this package is used to create image objects for manipulation, including methods for cropping, resizing, rotating, and flipping, as well as adjusting contrast and color levels automatically."],["The service supports both synchronous and asynchronous operations, allowing for efficient image manipulation and retrieval of image data and metadata."],["Several exceptions are defined in this module to handle issues such as invalid parameters, corrupt or unrecognised image data, permission issues, or if the image is too large to be processed."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4