Class ImagesServiceFactory (2.0.0)

public final class ImagesServiceFactory

Factory for creating an ImagesService, Images and Transforms.

Inheritance

java.lang.Object > ImagesServiceFactory

Static Methods

getImagesService()

public static ImagesService getImagesService()

Creates an implementation of the ImagesService.

Returns
Type Description
ImagesService

an images service

makeComposite(Image image, int xOffset, int yOffset, float opacity, Composite.Anchor anchor)

public static Composite makeComposite(Image image, int xOffset, int yOffset, float opacity, Composite.Anchor anchor)

Creates an image composition operation.

Parameters
Name Description
image Image

The image to be composited.

xOffset int

Offset in the x axis from the anchor point.

yOffset int

Offset in the y axis from the anchor point.

opacity float

Opacity to be used for the image in range [0.0, 1.0].

anchor Composite.Anchor

Anchor position from the enum Composite.Anchor. The anchor position of the image is aligned with the anchor position of the canvas and then the offsets are applied.

Returns
Type Description
Composite

A composition operation.

makeCompositeTransform()

public static CompositeTransform makeCompositeTransform()

Creates a composite transform that can represent multiple transforms applied in series.

Returns
Type Description
CompositeTransform

an empty composite transform

makeCompositeTransform(Collection<Transform> transforms)

public static CompositeTransform makeCompositeTransform(Collection<Transform> transforms)

Creates a composite transform that can represent multiple transforms applied in series.

Parameter
Name Description
transforms Collection<Transform>

Transforms for this composite transform to apply.

Returns
Type Description
CompositeTransform

a composite transform containing the provided transforms

makeCrop(double leftX, double topY, double rightX, double bottomY)

public static Transform makeCrop(double leftX, double topY, double rightX, double bottomY)

Creates a transform that will crop an image to fit within the bounding box specified.

The arguments define the top left and bottom right corners of the bounding box used to crop the image as a percentage of the total image size. Each argument should be in the range 0.0 to 1.0 inclusive.

Parameters
Name Description
leftX double

X coordinate of the top left corner of the bounding box

topY double

Y coordinate of the top left corner of the bounding box

rightX double

X coordinate of the bottom right corner of the bounding box

bottomY double

Y coordinate of the bottom right corner of the bounding box

Returns
Type Description
Transform

a crop transform

makeCrop(float leftX, float topY, float rightX, float bottomY)

public static Transform makeCrop(float leftX, float topY, float rightX, float bottomY)

Creates a transform that will crop an image to fit within the bounding box specified.

The arguments define the top left and bottom right corners of the bounding box used to crop the image as a percentage of the total image size. Each argument should be in the range 0.0 to 1.0 inclusive.

Parameters
Name Description
leftX float

X coordinate of the top left corner of the bounding box

topY float

Y coordinate of the top left corner of the bounding box

rightX float

X coordinate of the bottom right corner of the bounding box

bottomY float

Y coordinate of the bottom right corner of the bounding box

Returns
Type Description
Transform

a crop transform

makeHorizontalFlip()

public static Transform makeHorizontalFlip()

Creates a transform that will horizontally flip an image.

Returns
Type Description
Transform

a horizontal flip transform

makeImFeelingLucky()

public static Transform makeImFeelingLucky()

Creates a transform that automatically adjust contrast and color levels.

This is similar to the "I'm Feeling Lucky" button in Picasa.

Returns
Type Description
Transform

an ImFeelingLucky autolevel transform

makeImage(byte[] imageData)

public static Image makeImage(byte[] imageData)

Creates an image from the provided imageData.

Parameter
Name Description
imageData byte[]

image data to store in the image

Returns
Type Description
Image

an Image containing the supplied image data

makeImageFromBlob(BlobKey blobKey)

public static Image makeImageFromBlob(BlobKey blobKey)

Create an image backed by the specified blobKey. Note that the returned Image object can be used with all ImagesService methods, but most of the methods on the Image itself will currently throw UnsupportedOperationException.

Parameter
Name Description
blobKey BlobKey

referencing the image

Returns
Type Description
Image

an Image that references the specified blob data

makeImageFromFilename(String filename)

public static Image makeImageFromFilename(String filename)

Create an image backed by the specified filename. Note that the returned Image object can be used with all ImagesService methods, but most of the methods on the Image itself will currently throw UnsupportedOperationException.

Parameter
Name Description
filename String

referencing the image. Currently only Google Storage files in the format "/gs/bucket_name/object_name" are supported.

Returns
Type Description
Image

an Image that references the specified blob data

makeResize(int width, int height)

public static Transform makeResize(int width, int height)

Creates a transform that will resize an image to fit within a box with width width and height height.

Parameters
Name Description
width int

width of the bounding box

height int

height of the bounding box

Returns
Type Description
Transform

a resize transform

makeResize(int width, int height, boolean allowStretch)

public static Transform makeResize(int width, int height, boolean allowStretch)

Creates a resize transform that will resize an image to fit within a box of width width and height height. If allowStretch is true, the aspect ratio of the original image will be ignored.

Parameters
Name Description
width int

width of the bounding box

height int

height of the bounding box

allowStretch boolean

allow the image to be resized ignoring the aspect ratio

Returns
Type Description
Transform

a resize transform

makeResize(int width, int height, double cropOffsetX, double cropOffsetY)

public static Transform makeResize(int width, int height, double cropOffsetX, double cropOffsetY)

Creates a transform that will resize an image to exactly fit a box with width width and height height by resizing to the less constraining dimension and cropping the other. The center of the crop region is controlled by cropOffsetX and cropOffsetY.

Parameters
Name Description
width int

width of the bounding box

height int

height of the bounding box

cropOffsetX double

the relative horizontal position of the center

cropOffsetY double

the relative vertical position of the center

Returns
Type Description
Transform

a resize transform

makeResize(int width, int height, float cropOffsetX, float cropOffsetY)

public static Transform makeResize(int width, int height, float cropOffsetX, float cropOffsetY)

Creates a transform that will resize an image to exactly fit a box with width width and height height by resizing to the less constraining dimension and cropping the other. The center of the crop region is controlled by cropOffsetX and cropOffsetY.

Parameters
Name Description
width int

width of the bounding box

height int

height of the bounding box

cropOffsetX float

the relative horizontal position of the center

cropOffsetY float

the relative vertical position of the center

Returns
Type Description
Transform

a resize transform

makeRotate(int degrees)

public static Transform makeRotate(int degrees)

Creates a transform that rotates an image by degrees degrees clockwise.

Parameter
Name Description
degrees int

The number of degrees by which to rotate. Must be a multiple of 90.

Returns
Type Description
Transform

a rotation transform

makeVerticalFlip()

public static Transform makeVerticalFlip()

Creates a transform that will vertically flip an image.

Returns
Type Description
Transform

a vertical flip transform