public interface ImagesServiceThe 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 | |
|---|---|
| Type | Description |
int |
|
MAX_RESIZE_DIMENSIONS
public static final int MAX_RESIZE_DIMENSIONS| Field Value | |
|---|---|
| Type | Description |
int |
|
MAX_TRANSFORMS_PER_REQUEST
public static final int MAX_TRANSFORMS_PER_REQUEST| Field Value | |
|---|---|
| Type | Description |
int |
|
SERVING_CROP_SIZES
public static final Set<Integer> SERVING_CROP_SIZES| Field Value | |
|---|---|
| Type | Description |
Set<Integer> |
|
SERVING_SIZES
public static final Set<Integer> SERVING_SIZES| Field Value | |
|---|---|
| Type | Description |
Set<Integer> |
|
SERVING_SIZES_LIMIT
public static final int SERVING_SIZES_LIMIT| Field Value | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
transform |
Transformtransform to be applied |
image |
Imageimage to be transformed |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
transform |
Transformtransform to be applied |
image |
Imageimage to be transformed |
encoding |
ImagesService.OutputEncodingoutput encoding to be used |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
transform |
Transformtransform to be applied |
image |
Imageimage to be transformed |
inputSettings |
InputSettingsinput settings to be used |
outputSettings |
OutputSettingsoutput settings to be used |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
transform |
Transformtransform to be applied |
image |
Imageimage to be transformed |
settings |
OutputSettingsoutput settings to be used |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
transform |
Transformtransform to be applied |
image |
Imageimage to be transformed |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
transform |
Transformtransform to be applied |
image |
Imageimage to be transformed |
encoding |
ImagesService.OutputEncodingoutput encoding to be used |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
transform |
Transformtransform to be applied |
image |
Imageimage to be transformed |
inputSettings |
InputSettingsinput settings to be used |
outputSettings |
OutputSettingsoutput settings to be used |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
transform |
Transformtransform to be applied |
image |
Imageimage to be transformed |
settings |
OutputSettingsoutput settings to be used |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
composites |
Collection<Composite>Compositing operations to be applied. |
width |
intWidth of the canvas in pixels. |
height |
intHeight of the canvas in pixels. |
color |
longBackground color of the canvas in ARGB format. |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
composites |
Collection<Composite>Compositing operations to be applied. |
width |
intWidth of the canvas in pixels. |
height |
intHeight of the canvas in pixels. |
color |
longBackground color of the canvas in ARGB format. |
encoding |
ImagesService.OutputEncodingEncoding to be used for the resulting image. |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
composites |
Collection<Composite>Compositing operations to be applied. |
width |
intWidth of the canvas in pixels. |
height |
intHeight of the canvas in pixels. |
color |
longBackground color of the canvas in ARGB format. |
settings |
OutputSettingsOutputSettings to be used for the resulting image. |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
blobKey |
BlobKeyblob 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 | |
|---|---|
| Name | Description |
blobKey |
BlobKeyblob key of the image to serve by the returned URL. |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
blobKey |
BlobKeyblob key of the image to serve by the returned URL. |
secureUrl |
booleancontrols if the url scheme should be https or http. |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
blobKey |
BlobKeyblob key of the image to serve by the returned URL with specified size and crop. |
imageSize |
intsize of the served image in pixels. |
crop |
booleancontrols whether the image should be resized or cropped. |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
blobKey |
BlobKeyblob key of the image to serve by the returned URL with specified size and crop. |
imageSize |
intsize of the served image in pixels. |
crop |
booleancontrols whether the image should be resized or cropped. |
secureUrl |
booleancontrols if the url scheme should be https or http. |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
options |
ServingUrlOptionsSpecific options for generating the serving URL. |
| Returns | |
|---|---|
| Type | Description |
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 | |
|---|---|
| Name | Description |
image |
Imageimage for which to calculate a histogram |
| Returns | |
|---|---|
| Type | Description |
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. |