Class FileImageSource
- java.lang.Object
-
- net.coobird.thumbnailator.tasks.io.FileImageSource
-
- All Implemented Interfaces:
ImageSource<java.io.File>
public class FileImageSource extends java.lang.Object implements ImageSource<java.io.File>
AnImageSourcewhich reads the source image from a file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classFileImageSource.UninitializedImageSourceTemporary placeholderImageSourcewhich will be used before theFileImageSource.UninitializedImageSource.read()method is used.
-
Field Summary
Fields Modifier and Type Field Description private ImageSource<?>imageSourceAnImageSourcewhich actually performs the image source operations.private ThumbnailParameterparamAThumbnailParameterobject that is given bysetThumbnailParameter(ThumbnailParameter).private java.io.FilesourceFileThe file from which the image should be obtained.
-
Constructor Summary
Constructors Constructor Description FileImageSource(java.io.File sourceFile)Instantiates aFileImageSourcewith the specified file as the source image.FileImageSource(java.lang.String sourceFilePath)Instantiates aFileImageSourcewith the specified file as the source image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetInputFormatName()Returns the name of the image format.java.io.FilegetSource()Returns the source file from which an image is read.java.awt.image.BufferedImageread()Retrieves the image from the source.voidsetThumbnailParameter(ThumbnailParameter param)Sets theThumbnailParameterfrom which to retrieve parameters to use when retrieving the image.
-
-
-
Field Detail
-
sourceFile
private final java.io.File sourceFile
The file from which the image should be obtained.
-
imageSource
private ImageSource<?> imageSource
AnImageSourcewhich actually performs the image source operations. ThisImageSourcecan change during the lifecycle of theFileImageSourceclass.
-
param
private ThumbnailParameter param
AThumbnailParameterobject that is given bysetThumbnailParameter(ThumbnailParameter). This copy is needed when theimageSourceis being replacing during the lifecycle of this class.
-
-
Constructor Detail
-
FileImageSource
public FileImageSource(java.io.File sourceFile)
Instantiates aFileImageSourcewith the specified file as the source image.- Parameters:
sourceFile- The source image file.- Throws:
java.lang.NullPointerException- If the image is null.
-
FileImageSource
public FileImageSource(java.lang.String sourceFilePath)
Instantiates aFileImageSourcewith the specified file as the source image.- Parameters:
sourceFilePath- The filepath of the source image file.- Throws:
java.lang.NullPointerException- If the image is null.
-
-
Method Detail
-
read
public java.awt.image.BufferedImage read() throws java.io.IOExceptionDescription copied from interface:ImageSourceRetrieves the image from the source.- Specified by:
readin interfaceImageSource<java.io.File>- Returns:
- The image.
- Throws:
java.io.IOException- When a problem occurs while reading or obtaining the image.
-
getSource
public java.io.File getSource()
Returns the source file from which an image is read.- Specified by:
getSourcein interfaceImageSource<java.io.File>- Returns:
- The
Filerepresentation of the source file.
-
getInputFormatName
public java.lang.String getInputFormatName()
Description copied from interface:ImageSourceReturns the name of the image format.- Specified by:
getInputFormatNamein interfaceImageSource<java.io.File>- Returns:
- The image format name. If there is no
image format information, then
nullwill be returned.
-
setThumbnailParameter
public void setThumbnailParameter(ThumbnailParameter param)
Description copied from interface:ImageSourceSets theThumbnailParameterfrom which to retrieve parameters to use when retrieving the image.- Specified by:
setThumbnailParameterin interfaceImageSource<java.io.File>- Parameters:
param- TheThumbnailParameterwith image reading parameters.
-
-