public class ImageOption
extends java.lang.Object
CDAAsset.urlForImageWith(ImageOption...)
Modifier and Type | Class and Description |
---|---|
static class |
ImageOption.Focus
Defines the area of focus to crop to.
|
static class |
ImageOption.Format
Defines the possible formats of an image.
|
static class |
ImageOption.Resize
Defines the type of resizing possible.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
apply(java.lang.String url)
Apply this image option to a url, replacing and updating this url.
|
static ImageOption |
backgroundColorOf(int color)
Define a background color.
|
static ImageOption |
backgroundColorOf(int r,
int g,
int b)
Define a background color by its components.
|
static ImageOption |
blackBackgroundColor()
Define a background color as black.
|
static ImageOption |
fitOf(ImageOption.Resize resize)
Change the behaviour of resizing.
|
static ImageOption |
focusOn(ImageOption.Focus focus)
Changes the focus area when using the fit type of
ImageOption.Resize.thumb . |
static ImageOption |
formatOf(ImageOption.Format format)
Retrieve image of specific image format.
|
java.lang.String |
getOperation()
Return the operation of this option
|
static ImageOption |
heightOf(int height)
Set the height of the output image.
|
static ImageOption |
http()
Prefix image urls with http.
|
static ImageOption |
https()
Prefix image urls with secure http.
|
static ImageOption |
jpegQualityOf(int quality)
Define the quality of the jpg image to be returned.
|
static ImageOption |
roundedCornerRadiusOf(float radius)
Cut corners round.
|
static ImageOption |
widthOf(int width)
Define the width of the image to be represented.
|
public static ImageOption formatOf(ImageOption.Format format)
format
- an ImageOption.Format
to be used for returning the image.ImageOption.Format
public static ImageOption jpegQualityOf(int quality)
quality
- an positive integer between 1 and 100.java.lang.IllegalArgumentException
- if quality is not between 1 and 100.public static ImageOption widthOf(int width)
width
- width in pixel of the imagejava.lang.IllegalArgumentException
- if width is not positive.public static ImageOption heightOf(int height)
height
- size of image in pixel.java.lang.IllegalArgumentException
- if height is not positive.public static ImageOption fitOf(ImageOption.Resize resize)
By default the aspect ratio of the image is preserved when defining a size, or a width and height. Using this method, you can define a different resize behaviour.
resize
- the behaviour of resizingpublic static ImageOption focusOn(ImageOption.Focus focus)
ImageOption.Resize.thumb
.focus
- the area of focus.public static ImageOption roundedCornerRadiusOf(float radius)
radius
- of the inner circle in pixeljava.lang.IllegalArgumentException
- if the radius is negative.public static ImageOption backgroundColorOf(int color)
The color value must be a hexadecimal value, i.e. 0xFF0000 means red.
color
- the color in hex to be used.java.lang.IllegalArgumentException
- if the color is less then zero or greater then 0xFFFFFF.public static ImageOption backgroundColorOf(int r, int g, int b)
Each color component must be a hexadecimal in the range from 0 to 255 inclusively.
r
- the red color component in hex to be used.g
- the green color component in hex to be used.b
- the blue color component in hex to be used.java.lang.IllegalArgumentException
- if a component is less then zero or greater then 255.public static ImageOption blackBackgroundColor()
public static ImageOption http()
If a protocol (either http or https) was already specified, this one will be taken and this option will not have any effect.
public static ImageOption https()
If a protocol (either http or https) was already specified, this one will be taken and this option will not have any effect.
java.lang.IllegalArgumentException
- if http()
or this method was called before.public java.lang.String apply(java.lang.String url)
url
- a url to be handledpublic java.lang.String getOperation()
Copyright © 2019 Contentful, GmbH.. All Rights Reserved.