java.lang.Object
org.bzdev.imageio.ImageScaler
Class for scaling images.
The class supports various ways of specifying IO.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Get the height of the last image that was scaled.int
Get the width of the last image that was scaled.scaleImage
(int maxScaledWidth, int maxScaledHeight, Image image) Create a scaled buffered image file from an image.scaleImage
(int maxScaledWidth, int maxScaledHeight, String inputFileName) Create a scaled buffered Image file given a file name for the input image.void
scaleImage
(int maxScaledWidth, int maxScaledHeight, String inputFileName, File outputFile, String type) Create a scaled image file given a file name for the input image and a file for the output image.void
scaleImage
(int maxScaledWidth, int maxScaledHeight, String inputFileName, OutputStream os, String type) Create a scaled image file given a file name for the input image and an output stream for the output image.void
scaleImage
(int maxScaledWidth, int maxScaledHeight, String inFileName, String outFileName, String type) Create a scaled image file given file names for the input and output images.scaleImage
(int maxScaledWidth, int maxScaledHeight, URL url) Create a scaled buffered Image file given a URL for the input image.void
scaleImage
(int maxScaledWidth, int maxScaledHeight, URL url, File outputFile, String type) Create a scaled image file given a URL for the input image and a file for the output image.void
scaleImage
(int maxScaledWidth, int maxScaledHeight, URL url, OutputStream os, String type) Create a scaled image file given a URL for the input image and an output stream for the output image.
-
Constructor Details
-
ImageScaler
public ImageScaler()Constructor.
-
-
Method Details
-
scaleImage
public void scaleImage(int maxScaledWidth, int maxScaledHeight, String inFileName, String outFileName, String type) throws IllegalArgumentException, IOException, InterruptedException Create a scaled image file given file names for the input and output images. The supported input file formats are those supported by Java. The image will not be distorted and will be as large as possible while fitting into a rectangle whose height and width are given by the arguments maxScaledWidth and maxScaledHeight respectively.If both maxScaledWdith and MaxScaledHeight are -1, they are set to 0.
- Parameters:
maxScaledWidth
- the maximum width of a scaled image in pixels; 0 for the image width and -1 if the width is not constrainedmaxScaledHeight
- the maximum height of a scaled image in pixels; 0 for the image height and -1 if the height is not constrainedinFileName
- the name of the input fileoutFileName
- the name of the output filetype
- the image type to create:- Throws:
IllegalArgumentException
- generally an illegal input or output file nameIOException
- read or write operations failedInterruptedException
- the current thread was interrupted
-
getLastImageWidth
public int getLastImageWidth()Get the width of the last image that was scaled.- Returns:
- the image width in pixels
-
getLastImageHeight
public int getLastImageHeight()Get the height of the last image that was scaled.- Returns:
- the image height in pixels
-
scaleImage
public BufferedImage scaleImage(int maxScaledWidth, int maxScaledHeight, Image image) throws IllegalArgumentException, IOException, InterruptedException Create a scaled buffered image file from an image. The supported input file formats are those supported by Java. The image will not be distorted and will be as large as possible while fitting into a rectangle whose height and width are given by the arguments maxScaledWidth and maxScaledHeight respectively.If both maxScaledWdith and MaxScaledHeight are -1, they are set to 0.
- Parameters:
maxScaledWidth
- the maximum width of a scaled image in pixels; 0 for the image width and -1 if the width is not constrainedmaxScaledHeight
- the maximum height of a scaled image in pixels; 0 for the image height and -1 if the height is not constrainedimage
- the image to scale- Returns:
- a scaled image
- Throws:
IllegalArgumentException
- generally an illegal input or output file nameIOException
- read or write operations failedInterruptedException
- the current thread was interrupted
-
scaleImage
public BufferedImage scaleImage(int maxScaledWidth, int maxScaledHeight, String inputFileName) throws IllegalArgumentException, IOException, InterruptedException Create a scaled buffered Image file given a file name for the input image. The supported input file formats are those supported by Java. The image will not be distorted and will be as large as possible while fitting into a rectangle whose height and width are given by the arguments maxScaledWidth and maxScaledHeight respectively.If both maxScaledWdith and MaxScaledHeight are -1, they are set to 0.
- Parameters:
maxScaledWidth
- the maximum width of a scaled image in pixels; 0 for the image width and -1 if the width is not constrainedmaxScaledHeight
- the maximum height of a scaled image in pixels; 0 for the image height and -1 if the height is not constrainedinputFileName
- the name of the input file.- Returns:
- a scaled image
- Throws:
IllegalArgumentException
- generally an illegal input or output file nameIOException
- read or write operations failedInterruptedException
- the current thread was interrupted
-
scaleImage
public BufferedImage scaleImage(int maxScaledWidth, int maxScaledHeight, URL url) throws IllegalArgumentException, IOException, InterruptedException Create a scaled buffered Image file given a URL for the input image. The supported input file formats are those supported by Java. The image will not be distorted and will be as large as possible while fitting into a rectangle whose height and width are given by the arguments maxScaledWidth and maxScaledHeight respectively.If both maxScaledWdith and MaxScaledHeight are -1, they are set to 0.
- Parameters:
maxScaledWidth
- the maximum width of a scaled image in pixels; 0 for the image width and -1 if the width is not constrainedmaxScaledHeight
- the maximum height of a scaled image in pixels; 0 for the image height and -1 if the height is not constrainedurl
- the URL of the input image- Returns:
- a scaled image
- Throws:
IllegalArgumentException
- generally an illegal input or output file nameIOException
- read or write operations failedInterruptedException
- the current thread was interrupted
-
scaleImage
public void scaleImage(int maxScaledWidth, int maxScaledHeight, String inputFileName, File outputFile, String type) throws IllegalArgumentException, IOException, InterruptedException Create a scaled image file given a file name for the input image and a file for the output image. The supported input file formats are those supported by Java. The image will not be distorted and will be as large as possible while fitting into a rectangle whose height and width are given by the arguments maxScaledWidth and maxScaledHeight respectively.If both maxScaledWdith and MaxScaledHeight are -1, they are set to 0.
- Parameters:
maxScaledWidth
- the maximum width of a scaled image in pixels; 0 for the image width and -1 if the width is not constrainedmaxScaledHeight
- the maximum height of a scaled image in pixels; 0 for the image height and -1 if the height is not constrainedinputFileName
- the name of the input fileoutputFile
- the output filetype
- the image type to create:- Throws:
IllegalArgumentException
- generally an illegal input or output file nameIOException
- read or write operations failedInterruptedException
- the current thread was interrupted
-
scaleImage
public void scaleImage(int maxScaledWidth, int maxScaledHeight, URL url, File outputFile, String type) throws IllegalArgumentException, IOException, InterruptedException Create a scaled image file given a URL for the input image and a file for the output image. The supported input file formats are those supported by Java. The image will not be distorted and will be as large as possible while fitting into a rectangle whose height and width are given by the arguments maxScaledWidth and maxScaledHeight respectively.If both maxScaledWdith and MaxScaledHeight are -1, they are set to 0.
- Parameters:
maxScaledWidth
- the maximum width of a scaled image in pixels; 0 for the image width and -1 if the width is not constrainedmaxScaledHeight
- the maximum height of a scaled image in pixels; 0 for the image height and -1 if the height is not constrainedurl
- the URL for the image sourceoutputFile
- the output filetype
- the image type to create:- Throws:
IllegalArgumentException
- generally an illegal input or output file nameIOException
- read or write operations failedInterruptedException
- the current thread was interrupted
-
scaleImage
public void scaleImage(int maxScaledWidth, int maxScaledHeight, String inputFileName, OutputStream os, String type) throws IllegalArgumentException, IOException, InterruptedException Create a scaled image file given a file name for the input image and an output stream for the output image. The supported input file formats are those supported by Java. The image will not be distorted and will be as large as possible while fitting into a rectangle whose height and width are given by the arguments maxScaledWidth and maxScaledHeight respectively.If both maxScaledWdith and MaxScaledHeight are -1, they are set to 0.
- Parameters:
maxScaledWidth
- the maximum width of a scaled image in pixels; 0 for the image width and -1 if the width is not constrainedmaxScaledHeight
- the maximum height of a scaled image in pixels; 0 for the image height and -1 if the height is not constrainedinputFileName
- the name of the input fileos
- the output streamtype
- the image type to create:- Throws:
IllegalArgumentException
- generally an illegal input or output file nameIOException
- read or write operations failedInterruptedException
- the current thread was interrupted
-
scaleImage
public void scaleImage(int maxScaledWidth, int maxScaledHeight, URL url, OutputStream os, String type) throws IllegalArgumentException, IOException, InterruptedException Create a scaled image file given a URL for the input image and an output stream for the output image. The supported input file formats are those supported by Java.If both maxScaledWdith and MaxScaledHeight are -1, they are set to 0.
- Parameters:
maxScaledWidth
- the maximum width of a scaled image in pixels; 0 for the image width and -1 if the width is not constrainedmaxScaledHeight
- the maximum height of a scaled image in pixels; 0 for the image height and -1 if the height is not constrainedurl
- the URL for the image sourceos
- the output streamtype
- the image type to create:- Throws:
IllegalArgumentException
- generally an illegal input or output file nameIOException
- read or write operations failedInterruptedException
- the current thread was interrupted
-