public class ImageUtil extends Object
Constructor and Description |
---|
ImageUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
createThumb(InputStream input,
OutputStream output,
int thumbWidth,
int thumbHeight,
String format)
Create a reduced image (thumb) of an image from the given input stream.
|
static int[] |
getImageSize(InputStream input)
Returns the size (width and height) of an image from the given input
stream.
|
static int[] |
getImageSize(InputStream input,
int maxWidth,
int maxHeight)
Returns the possible size of an image from the given input stream; the
returned size does not overcome the specified maximal borders but keeps
the ratio of the image.
|
static int[] |
getNewSize(int width,
int height,
int maxWidth,
int maxHeight)
Calculates new size of an image with the specified max borders keeping
the ratio between height and width of the image.
|
public static void createThumb(InputStream input, OutputStream output, int thumbWidth, int thumbHeight, String format) throws IOException
input
- the input stream containing the image to reduceoutput
- the output stream where the resulting reduced image is
writtenthumbWidth
- the maximal width of the reduced imagethumbHeight
- the maximal height of the reduced imageformat
- the output format of the reduced image; it can be "jpg",
"png", ...IOException
public static int[] getImageSize(InputStream input) throws IOException
input
- the input stream with an imageIOException
public static int[] getImageSize(InputStream input, int maxWidth, int maxHeight) throws IOException
input
- the input stream with an imagemaxWidth
- the maximal widthmaxHeight
- the maximal heightIOException
public static int[] getNewSize(int width, int height, int maxWidth, int maxHeight)
width
- the initial width of an imageheight
- the initial height of an imagemaxWidth
- the maximal width of an imagemaxHeight
- the maximal height of an imageCopyright © 2004–2021 XWiki. All rights reserved.