Package net.coobird.thumbnailator.tasks
Class FileThumbnailTask
- java.lang.Object
-
- net.coobird.thumbnailator.tasks.ThumbnailTask<java.io.File,java.io.File>
-
- net.coobird.thumbnailator.tasks.FileThumbnailTask
-
public class FileThumbnailTask extends ThumbnailTask<java.io.File,java.io.File>
A thumbnail generation task which reads and writes data from and to aFile.Only the first image included in the image file will be read. Subsequent images included in the image file will be ignored.
-
-
Field Summary
Fields Modifier and Type Field Description private SourceSinkThumbnailTask<java.io.File,java.io.File>taskTheSourceSinkThumbnailTaskused to perform the task.-
Fields inherited from class net.coobird.thumbnailator.tasks.ThumbnailTask
FIRST_IMAGE_INDEX, inputFormatName, param
-
-
Constructor Summary
Constructors Constructor Description FileThumbnailTask(ThumbnailParameter param, java.io.File sourceFile, java.io.File destinationFile)Creates aThumbnailTaskin which image data is read from the specifiedFileand is output to a specifiedFile, using the parameters provided in the specifiedThumbnailParameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.FilegetDestination()Returns the destination to which the thumbnail is stored or written.ThumbnailParametergetParam()Returns theThumbnailParameterfor thisThumbnailTask, used when performing a thumbnail generation operation.java.io.FilegetSource()Returns the source from which the source image is retrieved or read.java.awt.image.BufferedImageread()Reads a source image.voidwrite(java.awt.image.BufferedImage img)Writes the thumbnail to the destination.
-
-
-
Field Detail
-
task
private final SourceSinkThumbnailTask<java.io.File,java.io.File> task
TheSourceSinkThumbnailTaskused to perform the task.
-
-
Constructor Detail
-
FileThumbnailTask
public FileThumbnailTask(ThumbnailParameter param, java.io.File sourceFile, java.io.File destinationFile)
Creates aThumbnailTaskin which image data is read from the specifiedFileand is output to a specifiedFile, using the parameters provided in the specifiedThumbnailParameter.- Parameters:
param- The parameters to use to create the thumbnail.sourceFile- TheFilefrom which image data is read.destinationFile- TheFileto which thumbnail is written.- Throws:
java.lang.NullPointerException- If the parameter isnull.
-
-
Method Detail
-
read
public java.awt.image.BufferedImage read() throws java.io.IOExceptionDescription copied from class:ThumbnailTaskReads a source image.- Specified by:
readin classThumbnailTask<java.io.File,java.io.File>- Returns:
- The image which was obtained from the source.
- Throws:
java.io.IOException- Thrown when an I/O problem occurs when reading from the image source.
-
write
public void write(java.awt.image.BufferedImage img) throws java.io.IOExceptionDescription copied from class:ThumbnailTaskWrites the thumbnail to the destination.- Specified by:
writein classThumbnailTask<java.io.File,java.io.File>- Parameters:
img- The image to write.- Throws:
UnsupportedFormatException- When an image file which is to be read or written is unsupported.java.io.IOException- Thrown when an I/O problem occurs when writing the image.
-
getParam
public ThumbnailParameter getParam()
Description copied from class:ThumbnailTaskReturns theThumbnailParameterfor thisThumbnailTask, used when performing a thumbnail generation operation.- Overrides:
getParamin classThumbnailTask<java.io.File,java.io.File>- Returns:
- The parameters to use when generating thumbnails.
-
getSource
public java.io.File getSource()
Description copied from class:ThumbnailTaskReturns the source from which the source image is retrieved or read.- Specified by:
getSourcein classThumbnailTask<java.io.File,java.io.File>- Returns:
- The source.
-
getDestination
public java.io.File getDestination()
Description copied from class:ThumbnailTaskReturns the destination to which the thumbnail is stored or written.- Specified by:
getDestinationin classThumbnailTask<java.io.File,java.io.File>- Returns:
- The destination.
-
-