Interface ImagesService (2.0.0)

public interface ImagesService

The images service provides methods to apply transformations to images.

Static Fields

MAX_COMPOSITES_PER_REQUEST

public static final int MAX_COMPOSITES_PER_REQUEST
Field Value
TypeDescription
int

MAX_RESIZE_DIMENSIONS

public static final int MAX_RESIZE_DIMENSIONS
Field Value
TypeDescription
int

MAX_TRANSFORMS_PER_REQUEST

public static final int MAX_TRANSFORMS_PER_REQUEST
Field Value
TypeDescription
int

SERVING_CROP_SIZES

public static final Set<Integer> SERVING_CROP_SIZES
Field Value
TypeDescription
Set<Integer>

SERVING_SIZES

public static final Set<Integer> SERVING_SIZES
Field Value
TypeDescription
Set<Integer>

SERVING_SIZES_LIMIT

public static final int SERVING_SIZES_LIMIT
Field Value
TypeDescription
int

Methods

applyTransform(Transform transform, Image image)

public abstract Image applyTransform(Transform transform, Image image)

Applies the provided transform to the provided image encoding the transformed image stored using PNG file format. The transform is applied in place to the provided image.

Parameters
NameDescription
transformTransform

transform to be applied

imageImage

image to be transformed

Returns
TypeDescription
Image

transformed image

applyTransform(Transform transform, Image image, ImagesService.OutputEncoding encoding)

public abstract Image applyTransform(Transform transform, Image image, ImagesService.OutputEncoding encoding)

Applies the provided transform to the provided image encoding the transformed image stored using encoding file format. The transform is applied in place to the provided image.

Parameters
NameDescription
transformTransform

transform to be applied

imageImage

image to be transformed

encodingImagesService.OutputEncoding

output encoding to be used

Returns
TypeDescription
Image

transformed image

applyTransform(Transform transform, Image image, InputSettings inputSettings, OutputSettings outputSettings)

public abstract Image applyTransform(Transform transform, Image image, InputSettings inputSettings, OutputSettings outputSettings)

Applies the provided transform to the provided image encoding the transformed image stored using outputSettings interpreting image according to inputSettings. The transform is applied in place to the provided image.

Parameters
NameDescription
transformTransform

transform to be applied

imageImage

image to be transformed

inputSettingsInputSettings

input settings to be used

outputSettingsOutputSettings

output settings to be used

Returns
TypeDescription
Image

transformed image

applyTransform(Transform transform, Image image, OutputSettings settings)

public abstract Image applyTransform(Transform transform, Image image, OutputSettings settings)

Applies the provided transform to the provided image encoding the transformed image stored using settings. The transform is applied in place to the provided image.

Parameters
NameDescription
transformTransform

transform to be applied

imageImage

image to be transformed

settingsOutputSettings

output settings to be used

Returns
TypeDescription
Image

transformed image

applyTransformAsync(Transform transform, Image image)

public abstract Future<Image> applyTransformAsync(Transform transform, Image image)

Asynchronously applies the provided transform to the provided image encoding the transformed image stored using PNG file format. The transform is applied in place to the provided image.

Parameters
NameDescription
transformTransform

transform to be applied

imageImage

image to be transformed

Returns
TypeDescription
Future<Image>

A future containing the transformed image or one of the exceptions documented for #applyTransform(Transform, Image).

applyTransformAsync(Transform transform, Image image, ImagesService.OutputEncoding encoding)

public abstract Future<Image> applyTransformAsync(Transform transform, Image image, ImagesService.OutputEncoding encoding)

Asynchronously applies the provided transform to the provided image encoding the transformed image stored using encoding file format. The transform is applied in place to the provided image.

Parameters
NameDescription
transformTransform

transform to be applied

imageImage

image to be transformed

encodingImagesService.OutputEncoding

output encoding to be used

Returns
TypeDescription
Future<Image>

A future containing the transformed image or one of the exceptions documented for #applyTransform(Transform, Image, OutputEncoding).

applyTransformAsync(Transform transform, Image image, InputSettings inputSettings, OutputSettings outputSettings)

public abstract Future<Image> applyTransformAsync(Transform transform, Image image, InputSettings inputSettings, OutputSettings outputSettings)

Asynchronously applies the provided transform to the provided image encoding the transformed image stored using settings interpreting image according to inputSettings. The transform is applied in place to the provided image.

Parameters
NameDescription
transformTransform

transform to be applied

imageImage

image to be transformed

inputSettingsInputSettings

input settings to be used

outputSettingsOutputSettings

output settings to be used

Returns
TypeDescription
Future<Image>

A future containing the transformed image or one of the exceptions documented for #applyTransform(Transform, Image, InputSettings, OutputSettings).

applyTransformAsync(Transform transform, Image image, OutputSettings settings)

public abstract Future<Image> applyTransformAsync(Transform transform, Image image, OutputSettings settings)

Asynchronously applies the provided transform to the provided image encoding the transformed image stored using settings. The transform is applied in place to the provided image.

Parameters
NameDescription
transformTransform

transform to be applied

imageImage

image to be transformed

settingsOutputSettings

output settings to be used

Returns
TypeDescription
Future<Image>

A future containing the transformed image or one of the exceptions documented for #applyTransform(Transform, Image, OutputSettings).

composite(Collection<Composite> composites, int width, int height, long color)

public abstract Image composite(Collection<Composite> composites, int width, int height, long color)

Applies the provided Collection of Composites using a canvas with dimensions determined by width and height and background color color. Uses PNG as its output encoding.

Parameters
NameDescription
compositesCollection<Composite>

Compositing operations to be applied.

widthint

Width of the canvas in pixels.

heightint

Height of the canvas in pixels.

colorlong

Background color of the canvas in ARGB format.

Returns
TypeDescription
Image

A new image containing the result of composition.

composite(Collection<Composite> composites, int width, int height, long color, ImagesService.OutputEncoding encoding)

public abstract Image composite(Collection<Composite> composites, int width, int height, long color, ImagesService.OutputEncoding encoding)

Applies the provided Collection of Composites using a canvas with dimensions determined by width and height and background color color.

Parameters
NameDescription
compositesCollection<Composite>

Compositing operations to be applied.

widthint

Width of the canvas in pixels.

heightint

Height of the canvas in pixels.

colorlong

Background color of the canvas in ARGB format.

encodingImagesService.OutputEncoding

Encoding to be used for the resulting image.

Returns
TypeDescription
Image

A new image containing the result of composition.

composite(Collection<Composite> composites, int width, int height, long color, OutputSettings settings)

public abstract Image composite(Collection<Composite> composites, int width, int height, long color, OutputSettings settings)

Applies the provided Collection of Composites using a canvas with dimensions determined by width and height and background color color.

Parameters
NameDescription
compositesCollection<Composite>

Compositing operations to be applied.

widthint

Width of the canvas in pixels.

heightint

Height of the canvas in pixels.

colorlong

Background color of the canvas in ARGB format.

settingsOutputSettings

OutputSettings to be used for the resulting image.

Returns
TypeDescription
Image

A new image containing the result of composition.

deleteServingUrl(BlobKey blobKey)

public abstract void deleteServingUrl(BlobKey blobKey)

Deletes a URL that was previously generated by getServingUrl(BlobKey).

Parameter
NameDescription
blobKeyBlobKey

blob key that was previously used in the call to create the serving URL.

getServingUrl(BlobKey blobKey) (deprecated)

public abstract String getServingUrl(BlobKey blobKey)

Deprecated. Replaced by #getServingUrl(ServingUrlOptions).

Obtains a URL that can serve the image stored as a blob dynamically.

This URL is served by a high-performance dynamic image serving infrastructure that is available globally. The URL returned by this method is always public, but not guessable; private URLs are not currently supported. If you wish to stop serving the URL, delete the underlying blob key. This takes up to 24 hours to take effect.

The URL format also allows dynamic resizing and crop with certain restrictions. To get dynamic resizing and cropping simply append options to the end of the url obtained via this call. Here is an example: getServingUrl -> "http://lh3.ggpht.com/SomeCharactersGoesHere"

To get a 32 pixel sized version (aspect-ratio preserved) simply append "=s32" to the url: "http://lh3.ggpht.com/SomeCharactersGoesHere=s32"

To get a 32 pixel cropped version simply append "=s32-c": "http://lh3.ggpht.com/SomeCharactersGoesHere=s32-c"

Valid sizes are any integer in the range [0, 1600] and is available as SERVING_SIZES_LIMIT.

Parameter
NameDescription
blobKeyBlobKey

blob key of the image to serve by the returned URL.

Returns
TypeDescription
String

a URL that can serve the image dynamically.

getServingUrl(BlobKey blobKey, boolean secureUrl) (deprecated)

public abstract String getServingUrl(BlobKey blobKey, boolean secureUrl)

Deprecated. Replaced by #getServingUrl(ServingUrlOptions).

Obtains a URL that can serve the image stored as a blob dynamically.

This URL is served by a high-performance dynamic image serving infrastructure that is available globally. The URL returned by this method is always public, but not guessable; private URLs are not currently supported. If you wish to stop serving the URL, delete the underlying blob key. This takes up to 24 hours to take effect.

The URL format also allows dynamic resizing and crop with certain restrictions. To get dynamic resizing and cropping simply append options to the end of the url obtained via this call. Here is an example: getServingUrl -> "http://lh3.ggpht.com/SomeCharactersGoesHere"

To get a 32 pixel sized version (aspect-ratio preserved) simply append "=s32" to the url: "http://lh3.ggpht.com/SomeCharactersGoesHere=s32"

To get a 32 pixel cropped version simply append "=s32-c": "http://lh3.ggpht.com/SomeCharactersGoesHere=s32-c"

Valid sizes are any integer in the range [0, 1600] and is available as SERVING_SIZES_LIMIT.

Parameters
NameDescription
blobKeyBlobKey

blob key of the image to serve by the returned URL.

secureUrlboolean

controls if the url scheme should be https or http.

Returns
TypeDescription
String

a URL that can serve the image dynamically.

getServingUrl(BlobKey blobKey, int imageSize, boolean crop) (deprecated)

public abstract String getServingUrl(BlobKey blobKey, int imageSize, boolean crop)

Deprecated. Replaced by #getServingUrl(ServingUrlOptions).

Calculates the serving URL for specific size and crop parameters from generic URL returned by #getServingUrl(BlobKey). See Also: ImagesService#getServingUrl(BlobKey)

Parameters
NameDescription
blobKeyBlobKey

blob key of the image to serve by the returned URL with specified size and crop.

imageSizeint

size of the served image in pixels.

cropboolean

controls whether the image should be resized or cropped.

Returns
TypeDescription
String

a URL that can serve the image dynamically.

getServingUrl(BlobKey blobKey, int imageSize, boolean crop, boolean secureUrl) (deprecated)

public abstract String getServingUrl(BlobKey blobKey, int imageSize, boolean crop, boolean secureUrl)

Deprecated. Replaced by #getServingUrl(ServingUrlOptions).

Calculates the serving URL for specific size and crop parameters from generic URL returned by #getServingUrl(BlobKey). See Also: ImagesService#getServingUrl(BlobKey)

Parameters
NameDescription
blobKeyBlobKey

blob key of the image to serve by the returned URL with specified size and crop.

imageSizeint

size of the served image in pixels.

cropboolean

controls whether the image should be resized or cropped.

secureUrlboolean

controls if the url scheme should be https or http.

Returns
TypeDescription
String

a URL that can serve the image dynamically.

getServingUrl(ServingUrlOptions options)

public abstract String getServingUrl(ServingUrlOptions options)

Obtains a URL that can dynamically serve the image stored as a blob.

This URL is served by a high-performance dynamic image serving infrastructure that is available globally. The URL returned by this method is always public, but not guessable; private URLs are not currently supported. If you wish to stop serving the URL, delete the underlying blob key. This takes up to 24 hours to take effect.

The URL format also allows dynamic resizing and crop with certain restrictions. To get dynamic resizing and cropping simply append options to the end of the url obtained via this call. Here is an example: getServingUrl -> "http://lh3.ggpht.com/SomeCharactersGoesHere"

To get a 32 pixel sized version (aspect-ratio preserved) simply append "=s32" to the url: "http://lh3.ggpht.com/SomeCharactersGoesHere=s32"

To get a 32 pixel cropped version simply append "=s32-c": "http://lh3.ggpht.com/SomeCharactersGoesHere=s32-c"

Valid sizes are any integer in the range [0, 1600] (maximum is available as #SERVING_SIZES_LIMIT).

Parameter
NameDescription
optionsServingUrlOptions

Specific options for generating the serving URL.

Returns
TypeDescription
String

a URL that can serve the image dynamically.

histogram(Image image)

public abstract int[][] histogram(Image image)

Calculates the histogram of the image.

Parameter
NameDescription
imageImage

image for which to calculate a histogram

Returns
TypeDescription
int[][]

An array of 3 arrays of length 256, each containing the image histogram for one color channel. The channels are ordered RGB from entry 0 to 3. Each channel ranges from 0 where the color is not present to 255 where the color is fully bright.