public class CdnPathBuilder
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CdnPathBuilder.ImageFormat |
static class |
CdnPathBuilder.ImageQuality |
Constructor and Description |
---|
CdnPathBuilder(File file)
Creates a new CDN path builder for some image file.
|
Modifier and Type | Method and Description |
---|---|
CdnPathBuilder |
blur()
Performs Gaussian blur on result image.
|
CdnPathBuilder |
blur(int strength)
Performs Gaussian blur on result image.
|
java.lang.String |
build()
Returns the current CDN path as a string.
|
CdnPathBuilder |
crop(int width,
int height)
Adds top-left-aligned crop.
|
CdnPathBuilder |
cropCenter(int width,
int height)
Adds center-aligned crop.
|
CdnPathBuilder |
cropCenterColor(int width,
int height,
java.awt.Color color)
Adds center-aligned crop with a filled background.
|
CdnPathBuilder |
cropColor(int width,
int height,
java.awt.Color color)
Adds top-left-aligned crop with a filled background.
|
CdnPathBuilder |
flip()
Flips the image.
|
CdnPathBuilder |
format(CdnPathBuilder.ImageFormat format)
Turn an image to one of the following formats: FORMAT_JPEG or FORMAT_PNG.
|
CdnPathBuilder |
grayscale()
Adds a grayscale effect.
|
CdnPathBuilder |
invert()
Inverts colors.
|
CdnPathBuilder |
mirror()
Horizontally mirror image.
|
CdnPathBuilder |
preview(int width,
int height)
Reduces an image proportionally in order to fit it into given dimensions.
|
CdnPathBuilder |
quality(CdnPathBuilder.ImageQuality quality)
Image quality affects size of image and loading speed.
|
CdnPathBuilder |
resize(int width,
int height)
Resizes width and height
|
CdnPathBuilder |
resizeHeight(int height)
Resizes height, keeping the aspect ratio.
|
CdnPathBuilder |
resizeWidth(int width)
Resizes width, keeping the aspect ratio.
|
CdnPathBuilder |
scaleCrop(int width,
int height)
Scales the image until one of the dimensions fits,
then crops the bottom or right side.
|
CdnPathBuilder |
scaleCropCenter(int width,
int height)
Scales the image until one of the dimensions fits,
centers it, then crops the rest.
|
CdnPathBuilder |
sharp()
Performs sharpening on result image.
|
CdnPathBuilder |
sharp(int strength)
Performs sharpening on result image.
|
public CdnPathBuilder(File file)
file
- File to be used for the pathFile.cdnPath()
public CdnPathBuilder crop(int width, int height)
width
- Crop widthheight
- Crop heightpublic CdnPathBuilder cropCenter(int width, int height)
width
- Crop widthheight
- Crop heightpublic CdnPathBuilder cropColor(int width, int height, java.awt.Color color)
width
- Crop widthheight
- Crop heightcolor
- Background colorpublic CdnPathBuilder cropCenterColor(int width, int height, java.awt.Color color)
width
- Crop widthheight
- Crop heightcolor
- Background colorpublic CdnPathBuilder resizeWidth(int width)
width
- New widthpublic CdnPathBuilder resizeHeight(int height)
height
- New heightpublic CdnPathBuilder resize(int width, int height)
width
- New widthheight
- New heightpublic CdnPathBuilder scaleCrop(int width, int height)
width
- New widthheight
- New heightpublic CdnPathBuilder scaleCropCenter(int width, int height)
width
- New widthheight
- New heightpublic CdnPathBuilder flip()
public CdnPathBuilder grayscale()
public CdnPathBuilder invert()
public CdnPathBuilder mirror()
public CdnPathBuilder blur()
public CdnPathBuilder blur(int strength)
strength
- Strength is standard deviation (aka blur radius) multiplied by ten. Strength
can be up to 5000. Default is 10.public CdnPathBuilder sharp()
public CdnPathBuilder sharp(int strength)
strength
- Strength can be from 0 to 20. Default is 5.public CdnPathBuilder preview(int width, int height)
width
- New widthheight
- New heightpublic CdnPathBuilder format(CdnPathBuilder.ImageFormat format)
format
- @link ImageFormat.public CdnPathBuilder quality(CdnPathBuilder.ImageQuality quality)
quality
- @link ImageQuality
QUALITY_NORMAL – used by default. Fine in most cases.
QUALITY_BETTER – can be used on relatively small previews with lots of details. ≈125% file size compared to normal image.
QUALITY_BEST – useful if you're a photography god and you want to get perfect quality without paying attention to size. ≈170% file size.
QUALITY_LIGHTER – can be used on relatively large images to save traffic without significant quality loss. ≈80% file size.
QUALITY_LIGHTEST — useful for retina resolutions, when you don't wory about quality of each pixel. ≈50% file size.public java.lang.String build()
Urls.cdn(CdnPathBuilder)