Package com.google.appengine.api.images
Interface IImagesServiceFactory
-
public interface IImagesServiceFactory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ImagesServicegetImagesService()Creates an implementation of the ImagesService.CompositemakeComposite(Image image, int xOffset, int yOffset, float opacity, Composite.Anchor anchor)Creates an image composition operation.CompositeTransformmakeCompositeTransform()Creates a composite transform that can represent multiple transforms applied in series.CompositeTransformmakeCompositeTransform(Collection<Transform> transforms)Creates a composite transform that can represent multiple transforms applied in series.TransformmakeCrop(double leftX, double topY, double rightX, double bottomY)Creates a transform that will crop an image to fit within the bounding box specified.TransformmakeCrop(float leftX, float topY, float rightX, float bottomY)Creates a transform that will crop an image to fit within the bounding box specified.TransformmakeHorizontalFlip()Creates a transform that will horizontally flip an image.ImagemakeImage(byte[] imageData)Creates an image from the providedimageData.ImagemakeImageFromBlob(BlobKey blobKey)Create an image backed by the specifiedblobKey.ImagemakeImageFromFilename(String filename)Create an image backed by the specifiedfilename.TransformmakeImFeelingLucky()Creates a transform that automatically adjust contrast and color levels.TransformmakeResize(int width, int height)Creates a transform that will resize an image to fit within a box with widthwidthand heightheight.TransformmakeResize(int width, int height, boolean allowStretch)Creates a resize transform that will resize an image to fit within a box of widthwidthand heightheight.TransformmakeResize(int width, int height, double cropOffsetX, double cropOffsetY)Creates a transform that will resize an image to exactly fit a box with widthwidthand heightheightby resizing to the less constraining dimension and cropping the other.TransformmakeResize(int width, int height, float cropOffsetX, float cropOffsetY)Creates a transform that will resize an image to exactly fit a box with widthwidthand heightheightby resizing to the less constraining dimension and cropping the other.TransformmakeRotate(int degrees)Creates a transform that rotates an image bydegreesdegrees clockwise.TransformmakeVerticalFlip()Creates a transform that will vertically flip an image.
-
-
-
Method Detail
-
getImagesService
ImagesService getImagesService()
Creates an implementation of the ImagesService.- Returns:
- an images service
-
makeImage
Image makeImage(byte[] imageData)
Creates an image from the providedimageData.- Parameters:
imageData- image data to store in the image- Returns:
- an Image containing the supplied image data
- Throws:
IllegalArgumentException- IfimageDatais null or empty.
-
makeImageFromBlob
Image makeImageFromBlob(BlobKey blobKey)
Create an image backed by the specifiedblobKey. Note that the returnedImageobject can be used with allImagesServicemethods, but most of the methods on the Image itself will currently throwUnsupportedOperationException.- Parameters:
blobKey- referencing the image- Returns:
- an Image that references the specified blob data
-
makeImageFromFilename
Image makeImageFromFilename(String filename)
Create an image backed by the specifiedfilename. Note that the returnedImageobject can be used with allImagesServicemethods, but most of the methods on the Image itself will currently throwUnsupportedOperationException.- Parameters:
filename- referencing the image. Currently only Google Storage files in the format "/gs/bucket_name/object_name" are supported.- Returns:
- an Image that references the specified blob data
- Throws:
IllegalArgumentException- Iffilenameis not in the format "/gs/bucket_name/object_name".BlobstoreFailureException- If there is an error obtaining the Google Storage access token for thefilename.
-
makeResize
Transform makeResize(int width, int height)
Creates a transform that will resize an image to fit within a box with widthwidthand heightheight.- Parameters:
width- width of the bounding boxheight- height of the bounding box- Returns:
- a resize transform
- Throws:
IllegalArgumentException- Ifwidthorheightare negative or greater thanMAX_RESIZE_DIMENSIONSor if bothwidthandheightare 0.
-
makeResize
Transform makeResize(int width, int height, boolean allowStretch)
Creates a resize transform that will resize an image to fit within a box of widthwidthand heightheight. IfallowStretchistrue, the aspect ratio of the original image will be ignored.- Parameters:
width- width of the bounding boxheight- height of the bounding boxallowStretch- allow the image to be resized ignoring the aspect ratio- Returns:
- a resize transform
- Throws:
IllegalArgumentException- Ifwidthorheightare negative or greater thanMAX_RESIZE_DIMENSIONS, if bothwidthandheightare 0 or ifallowStretchis True and eitherwidthorheightare 0.
-
makeResize
Transform makeResize(int width, int height, float cropOffsetX, float cropOffsetY)
Creates a transform that will resize an image to exactly fit a box with widthwidthand heightheightby resizing to the less constraining dimension and cropping the other. The center of the crop region is controlled bycropOffsetXandcropOffsetY.- Parameters:
width- width of the bounding boxheight- height of the bounding boxcropOffsetX- the relative horizontal position of the centercropOffsetY- the relative vertical position of the center- Returns:
- a resize transform
- Throws:
IllegalArgumentException- Ifwidthorheightare negative or greater thanMAX_RESIZE_DIMENSIONS, if either ofwidthandheightare 0 or ifcropOffsetXorcropOffsetYare outside the range 0.0 to 1.0.
-
makeResize
Transform makeResize(int width, int height, double cropOffsetX, double cropOffsetY)
Creates a transform that will resize an image to exactly fit a box with widthwidthand heightheightby resizing to the less constraining dimension and cropping the other. The center of the crop region is controlled bycropOffsetXandcropOffsetY.- Parameters:
width- width of the bounding boxheight- height of the bounding boxcropOffsetX- the relative horizontal position of the centercropOffsetY- the relative vertical position of the center- Returns:
- a resize transform
- Throws:
IllegalArgumentException- Ifwidthorheightare negative or greater thanMAX_RESIZE_DIMENSIONS, if either ofwidthandheightare 0 or ifcropOffsetXorcropOffsetYare outside the range 0.0 to 1.0.
-
makeCrop
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:
leftX- X coordinate of the top left corner of the bounding boxtopY- Y coordinate of the top left corner of the bounding boxrightX- X coordinate of the bottom right corner of the bounding boxbottomY- Y coordinate of the bottom right corner of the bounding box- Returns:
- a crop transform
- Throws:
IllegalArgumentException- If any of the arguments are outside the range 0.0 to 1.0 or ifleftX >= rightXortopY >= bottomY.
-
makeCrop
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:
leftX- X coordinate of the top left corner of the bounding boxtopY- Y coordinate of the top left corner of the bounding boxrightX- X coordinate of the bottom right corner of the bounding boxbottomY- Y coordinate of the bottom right corner of the bounding box- Returns:
- a crop transform
- Throws:
IllegalArgumentException- If any of the arguments are outside the range 0.0 to 1.0 or ifleftX >= rightXortopY >= bottomY.
-
makeVerticalFlip
Transform makeVerticalFlip()
Creates a transform that will vertically flip an image.- Returns:
- a vertical flip transform
-
makeHorizontalFlip
Transform makeHorizontalFlip()
Creates a transform that will horizontally flip an image.- Returns:
- a horizontal flip transform
-
makeRotate
Transform makeRotate(int degrees)
Creates a transform that rotates an image bydegreesdegrees clockwise.- Parameters:
degrees- The number of degrees by which to rotate. Must be a multiple of 90.- Returns:
- a rotation transform
- Throws:
IllegalArgumentException- Ifdegreesis not divisible by 90
-
makeImFeelingLucky
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:
- an ImFeelingLucky autolevel transform
-
makeCompositeTransform
CompositeTransform makeCompositeTransform(Collection<Transform> transforms)
Creates a composite transform that can represent multiple transforms applied in series.- Parameters:
transforms- Transforms for this composite transform to apply.- Returns:
- a composite transform containing the provided transforms
-
makeCompositeTransform
CompositeTransform makeCompositeTransform()
Creates a composite transform that can represent multiple transforms applied in series.- Returns:
- an empty composite transform
-
makeComposite
Composite makeComposite(Image image, int xOffset, int yOffset, float opacity, Composite.Anchor anchor)
Creates an image composition operation.- Parameters:
image- The image to be composited.xOffset- Offset in the x axis from the anchor point.yOffset- Offset in the y axis from the anchor point.opacity- Opacity to be used for the image in range [0.0, 1.0].anchor- Anchor position from the enumComposite.Anchor. The anchor position of the image is aligned with the anchor position of the canvas and then the offsets are applied.- Returns:
- A composition operation.
- Throws:
IllegalArgumentException- Ifimageis null or empty,xOffsetoryOffsetis outside the range [-4000, 4000],opacityis outside the range [0.0, 1.0] oranchoris null.
-
-