public final class ThumborUrlBuilder extends Object
Thumbor.buildImage(String)| Modifier and Type | Class and Description |
|---|---|
static class |
ThumborUrlBuilder.FitInStyle
Style of resizing for 'fit-in'.
|
static class |
ThumborUrlBuilder.HorizontalAlign
Horizontal alignment for crop positioning.
|
static class |
ThumborUrlBuilder.ImageFormat
Image formats supported by Thumbor.
|
static class |
ThumborUrlBuilder.TrimPixelColor
Orientation from where to get the pixel color for trim.
|
static class |
ThumborUrlBuilder.VerticalAlign
Vertical alignment for crop positioning.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
ORIGINAL_SIZE
Original size for image width or height.
|
| Modifier and Type | Method and Description |
|---|---|
ThumborUrlBuilder |
align(ThumborUrlBuilder.HorizontalAlign align)
Set the horizontal alignment for the image when image gets cropped by resizing.
|
ThumborUrlBuilder |
align(ThumborUrlBuilder.VerticalAlign align)
Set the vertical alignment for the image when image gets cropped by resizing.
|
ThumborUrlBuilder |
align(ThumborUrlBuilder.VerticalAlign valign,
ThumborUrlBuilder.HorizontalAlign halign)
Set the horizontal and vertical alignment for the image when image gets cropped by resizing.
|
static String |
blur(int radius)
This filter adds a blur effect to the image using the specified radius and a default
sigma (equal to the radius).
|
static String |
blur(int radius,
int sigma)
This filter adds a blur effect to the image using the specified radius and sigma.
|
static String |
brightness(int amount)
This filter increases or decreases the image brightness.
|
static String |
contrast(int amount)
The filter increases or decreases the image contrast.
|
ThumborUrlBuilder |
crop(int top,
int left,
int bottom,
int right)
Crop the image between two points.
|
static String |
equalize()
This filter equalizes the color distribution in the image.
|
static String |
fill(int color)
This filter permit to return an image sized exactly as requested wherever is its ratio by
filling with chosen color the missing parts.
|
ThumborUrlBuilder |
filter(String... filters)
Add one or more filters to the image.
|
ThumborUrlBuilder |
fitIn()
Constrain the image size inside the resized box, scaling as needed.
|
ThumborUrlBuilder |
fitIn(ThumborUrlBuilder.FitInStyle fitInStyle)
Constrain the image size inside the resized box, scaling as needed.
|
ThumborUrlBuilder |
flipHorizontally()
Flip the image horizontally.
|
ThumborUrlBuilder |
flipVertically()
Flip the image vertically.
|
static String |
format(ThumborUrlBuilder.ImageFormat format)
Specify the output format of the image.
|
static String |
frame(String imageUrl)
This filter uses a 9-patch to overlay the image.
|
static String |
grayscale()
This filter changes the image to grayscale.
|
ThumborUrlBuilder |
legacy()
Use legacy encryption when constructing a safe URL.
|
static String |
noise(int amount)
This filter adds noise to the image.
|
static String |
noUpscale()
This filter tells thumbor not to upscale your images.
|
static String |
quality(int amount)
This filter changes the overall quality of the JPEG image (does nothing for PNGs or GIFs).
|
ThumborUrlBuilder |
resize(int width,
int height)
Resize picture to desired size.
|
static String |
rgb(int r,
int g,
int b)
This filter changes the amount of color in each of the three channels.
|
static String |
rotate(int angle)
This filter rotates the given image according to the angle passed.
|
static String |
roundCorner(int radius)
This filter adds rounded corners to the image using the white as the background.
|
static String |
roundCorner(int radius,
int color)
This filter adds rounded corners to the image using the specified color as the background.
|
static String |
roundCorner(int radiusInner,
int radiusOuter,
int color)
This filter adds rounded corners to the image using the specified color as the background.
|
static String |
sharpen(float amount,
float radius,
boolean luminanceOnly)
This filter enhances apparent sharpness of the image.
|
ThumborUrlBuilder |
smart()
Use smart cropping for determining the important portion of an image.
|
static String |
stripicc()
This filter strips the ICC profile from the image.
|
String |
toMeta()
Build the metadata URL.
|
String |
toMetaSafe()
Build a safe version of the metadata URL.
|
String |
toMetaUnsafe()
Build an unsafe version of the metadata URL.
|
String |
toString() |
String |
toUrl()
Build the URL.
|
String |
toUrlSafe()
Build a safe version of the URL.
|
String |
toUrlUnsafe()
Build an unsafe version of the URL.
|
ThumborUrlBuilder |
trim()
Removing surrounding space in image.
|
ThumborUrlBuilder |
trim(ThumborUrlBuilder.TrimPixelColor value)
Removing surrounding space in image.
|
ThumborUrlBuilder |
trim(ThumborUrlBuilder.TrimPixelColor value,
int colorTolerance)
Removing surrounding space in image.
|
static String |
watermark(String imageUrl)
This filter adds a watermark to the image at (0, 0).
|
static String |
watermark(String imageUrl,
int x,
int y)
This filter adds a watermark to the image.
|
static String |
watermark(String imageUrl,
int x,
int y,
int transparency)
This filter adds a watermark to the image.
|
static String |
watermark(ThumborUrlBuilder image)
This filter adds a watermark to the image at (0, 0).
|
static String |
watermark(ThumborUrlBuilder image,
int x,
int y)
This filter adds a watermark to the image.
|
static String |
watermark(ThumborUrlBuilder image,
int x,
int y,
int transparency)
This filter adds a watermark to the image.
|
public static final int ORIGINAL_SIZE
public ThumborUrlBuilder resize(int width, int height)
width - Desired width.height - Desired height.IllegalArgumentException - if width or height is less than 0 or both are
0.public ThumborUrlBuilder flipHorizontally()
IllegalStateException - if image has not been marked for resize.public ThumborUrlBuilder flipVertically()
IllegalStateException - if image has not been marked for resize.public ThumborUrlBuilder fitIn()
IllegalStateException - if image has not been marked for resize.public ThumborUrlBuilder fitIn(ThumborUrlBuilder.FitInStyle fitInStyle)
IllegalStateException - if image has not been marked for resize.public ThumborUrlBuilder crop(int top, int left, int bottom, int right)
top - Top bound.left - Left bound.bottom - Bottom bound.right - Right bound.IllegalArgumentException - if top or left are less than zero or bottom or right are less than one or less than top or left,
respectively.public ThumborUrlBuilder align(ThumborUrlBuilder.HorizontalAlign align)
align - Horizontal alignment.IllegalStateException - if image has not been marked for resize.public ThumborUrlBuilder align(ThumborUrlBuilder.VerticalAlign align)
align - Vertical alignment.IllegalStateException - if image has not been marked for resize.public ThumborUrlBuilder align(ThumborUrlBuilder.VerticalAlign valign, ThumborUrlBuilder.HorizontalAlign halign)
valign - Vertical alignment.halign - Horizontal alignment.IllegalStateException - if image has not been marked for resize.public ThumborUrlBuilder smart()
IllegalStateException - if image has not been marked for resize.public ThumborUrlBuilder trim()
public ThumborUrlBuilder trim(ThumborUrlBuilder.TrimPixelColor value)
value - orientation from where to get the pixel color.public ThumborUrlBuilder trim(ThumborUrlBuilder.TrimPixelColor value, int colorTolerance)
value - orientation from where to get the pixel color.colorTolerance - 0 - 442. This is the euclidian distance
between the colors of the reference pixel and the surrounding pixels is used.
If the distance is within the tolerance they'll get trimmed.public ThumborUrlBuilder legacy()
public ThumborUrlBuilder filter(String... filters)
If you have custom filters you can supply them as a string. (e.g.
"my_filter(1,2,3)").
filters - Filter strings.IllegalArgumentException - if no arguments supplied or an argument is null.brightness(int),
contrast(int),
fill(int),
frame(String),
noise(int),
quality(int),
rgb(int, int, int),
roundCorner(int),
roundCorner(int, int),
roundCorner(int, int, int),
sharpen(float, float, boolean),
watermark(String),
watermark(ThumborUrlBuilder),
watermark(String, int, int),
watermark(ThumborUrlBuilder, int, int),
watermark(String, int, int, int),
watermark(ThumborUrlBuilder, int, int, int)public String toUrl()
toUrlSafe() or toUrlUnsafe() depending
on whether a key was set.public String toUrlUnsafe()
public String toUrlSafe()
null key.public String toMeta()
toMetaSafe() or toMetaUnsafe()
depending on whether a key was set.public String toMetaUnsafe()
public String toMetaSafe()
null key.public static String brightness(int amount)
amount - -100 to 100 - The amount (in %) to change the image brightness. Positive numbers
make the image brighter and negative numbers make the image darker.IllegalArgumentException - if amount outside bounds.public static String contrast(int amount)
amount - -100 to 100 - The amount (in %) to change the image contrast. Positive numbers
increase contrast and negative numbers decrease contrast.IllegalArgumentException - if amount outside bounds.public static String noise(int amount)
amount - 0 to 100 - The amount (in %) of noise to add to the image.IllegalArgumentException - if amount outside bounds.public static String quality(int amount)
amount - 0 to 100 - The quality level (in %) that the end image will feature.IllegalArgumentException - if amount outside bounds.public static String rgb(int r, int g, int b)
r - The amount of redness in the picture. Can range from -100 to 100 in percentage.g - The amount of greenness in the picture. Can range from -100 to 100 in percentage.b - The amount of blueness in the picture. Can range from -100 to 100 in percentage.IllegalArgumentException - if r, g, or b are outside of bounds.public static String roundCorner(int radius)
radius - amount of pixels to use as radius.public static String roundCorner(int radius, int color)
radius - amount of pixels to use as radius.color - fill color for clipped region.public static String roundCorner(int radiusInner, int radiusOuter, int color)
radiusInner - amount of pixels to use as radius.radiusOuter - specifies the second value for the ellipse used for the radius. Use 0 for
no value.color - fill color for clipped region.public static String watermark(String imageUrl)
imageUrl - Watermark image URL. It is very important to understand that the same image
loader that Thumbor uses will be used here.IllegalArgumentException - if image is blank.public static String watermark(ThumborUrlBuilder image)
image - Watermark image URL. It is very important to understand that the same image
loader that Thumbor uses will be used here.IllegalArgumentException - if image is null.public static String watermark(String imageUrl, int x, int y)
imageUrl - Watermark image URL. It is very important to understand that the same image
loader that Thumbor uses will be used here.x - Horizontal position that the watermark will be in. Positive numbers indicate position
from the left and negative numbers indicate position from the right.y - Vertical position that the watermark will be in. Positive numbers indicate position
from the top and negative numbers indicate position from the bottom.IllegalArgumentException - if image is blank.public static String watermark(ThumborUrlBuilder image, int x, int y)
image - Watermark image URL. It is very important to understand that the same image
loader that Thumbor uses will be used here.x - Horizontal position that the watermark will be in. Positive numbers indicate position
from the left and negative numbers indicate position from the right.y - Vertical position that the watermark will be in. Positive numbers indicate position
from the top and negative numbers indicate position from the bottom.IllegalArgumentException - if image is null.public static String watermark(String imageUrl, int x, int y, int transparency)
imageUrl - Watermark image URL. It is very important to understand that the same image
loader that Thumbor uses will be used here.x - Horizontal position that the watermark will be in. Positive numbers indicate position
from the left and negative numbers indicate position from the right.y - Vertical position that the watermark will be in. Positive numbers indicate position
from the top and negative numbers indicate position from the bottom.transparency - Watermark image transparency. Should be a number between 0 (fully opaque)
and 100 (fully transparent).IllegalArgumentException - if image is blank or transparency is outside
bounds.public static String watermark(ThumborUrlBuilder image, int x, int y, int transparency)
image - Watermark image URL. It is very important to understand that the same image
loader that Thumbor uses will be used here.x - Horizontal position that the watermark will be in. Positive numbers indicate position
from the left and negative numbers indicate position from the right.y - Vertical position that the watermark will be in. Positive numbers indicate position
from the top and negative numbers indicate position from the bottom.transparency - Watermark image transparency. Should be a number between 0 (fully opaque)
and 100 (fully transparent).IllegalArgumentException - if image is null.public static String sharpen(float amount, float radius, boolean luminanceOnly)
amount - Sharpen amount. Typical values are between 0.0 and 10.0.radius - Sharpen radius. Typical values are between 0.0 and 2.0.luminanceOnly - Sharpen only luminance channel.public static String fill(int color)
color - integer representation of color.public static String format(ThumborUrlBuilder.ImageFormat format)
ThumborUrlBuilder.ImageFormatpublic static String frame(String imageUrl)
imageUrl - Watermark image URL. It is very important to understand that the same image
loader that Thumbor uses will be used here.public static String stripicc()
public static String grayscale()
public static String equalize()
public static String blur(int radius)
radius - Radius used in the gaussian function to generate a matrix, maximum value is 150.
The bigger the radius more blurred will be the image.public static String blur(int radius, int sigma)
radius - Radius used in the gaussian function to generate a matrix, maximum value is 150.
The bigger the radius more blurred will be the image.sigma - Sigma used in the gaussian function.public static String noUpscale()
public static String rotate(int angle)
angle - The angle of rotation. Values can be either 0°, 90°, 180° or 270° – multiples of
90°. Angles equal to or greater than 360° will be replaced by their coterminal
angle of rotation.Copyright © 2012-2015 Square, Inc.. All Rights Reserved.