English
Skip to page content Skip to main navigation

e.g. "templates" or "datastore"

# Images Java API Overview

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 an predefined algorithm. The API can also provide information about an image, such as its format, width, height, and a histogram of color values.

- Transforming Images in Java
- Available Image Transformations
- Image Formats
- Images and the Development Server
- Quotas and Limits

## Transforming Images in Java

The Image service Java API lets you apply transformations to images, using a service instead of performing image processing on the application server. The app prepares an Image object with the image data to transform, and a Transform object with instructions on how to transform the image. The app gets an ImagesService object, then calls its `applyTransform()` method with the Image and the Transform objects. The method returns an Image object of the transformed image.

The app gets ImagesService, Image and Transform instances using the ImagesServiceFactory.

    import com.google.appengine.api.images.Image;
    import com.google.appengine.api.images.ImagesService;
    import com.google.appengine.api.images.ImagesServiceFactory;
    import com.google.appengine.api.images.Transform;

    // ...
            byte[] oldImageData;  // ...

            ImagesService imagesService = ImagesServiceFactory.getImagesService();

            Image oldImage = ImagesServiceFactory.makeImage(oldImageData);
            Transform resize = ImagesServiceFactory.makeResize(200, 300);

            Image newImage = imagesService.applyTransform(resize, oldImage);

            byte[] newImageData = newImage.getImageData();

Multiple transforms can be combined into a single action using a CompositeTransform instance. See the images API reference.

## Available Image Transformations

The Images service can resize, rotate, flip, and crop images, and enhance photographs. It can also composite multiple images into a single image.

#### Resize

You can resize the image while maintaining the same aspect ratio.

#### Rotate

You can rotate the image in 90 degree increments.

#### Flip Horizontally

You can flip the image horizontally.

#### Flip Vertically

You can flip the image vertically.

#### Crop

You can crop the image with a given bounding box.

#### I'm Feeling Lucky

The "I'm Feeling Lucky" transform enhances dark and bright colors in an image and adjusts both color and contrast to optimal levels.

## Image Formats

The service accepts image data in the JPEG, PNG, GIF (including animated GIF), BMP, TIFF and ICO formats.

It can return transformed images in the JPEG and PNG formats. If the input format and the output format are different, the service converts the input data to the output format before performing the transformation.

## Images and the Development Server

The development server uses your local machine to perform the capabilities of the Images service.

The Java development server includes functionality to simulate the Image service. The "I'm Feeling Lucky" photo enhancement feature is not supported.

## Quotas and Limits

Each Images service request counts toward the Image Manipulation API Calls quota. An app can perform multiple transformations of an image in a single API call.

Data sent to the Images service counts toward the Data Sent to (Images) API quota. Data received from the Images service counts toward the Data Received from (Images) API quota.

Each transformation of an image counts toward the Transformations Executed quota.

For more information on quotas, see Quotas, and the "Quota Details" section of the Admin Console.

In addition to quotas, the following limits apply to the use of the Images service:

Limit | Amount
--- | ---
maximum data size of image sent to service | 1 megabyte
maximum data size of image received from service | 1 megabyte