Package net.coobird.thumbnailator.tasks
Class StreamThumbnailTask
- java.lang.Object
-
- net.coobird.thumbnailator.tasks.ThumbnailTask<java.io.InputStream,java.io.OutputStream>
-
- net.coobird.thumbnailator.tasks.StreamThumbnailTask
-
public class StreamThumbnailTask extends ThumbnailTask<java.io.InputStream,java.io.OutputStream>
A thumbnail generation task which streams data from anInputStreamto anOutputStream.This class does not close the
InputStreamandOutputStreamupon the completion of processing.Only the first image obtained from the data stream will be read. Subsequent images will be ignored.
-
-
Field Summary
Fields Modifier and Type Field Description private SourceSinkThumbnailTask<java.io.InputStream,java.io.OutputStream>taskTheSourceSinkThumbnailTaskused to perform the task.-
Fields inherited from class net.coobird.thumbnailator.tasks.ThumbnailTask
FIRST_IMAGE_INDEX, inputFormatName, param
-
-
Constructor Summary
Constructors Constructor Description StreamThumbnailTask(ThumbnailParameter param, java.io.InputStream is, java.io.OutputStream os)Creates aThumbnailTaskin which streamed image data from the specifiedInputStreamis output to a specifiedOutputStream, using the parameters provided in the specifiedThumbnailParameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.OutputStreamgetDestination()Returns the destination to which the thumbnail is stored or written.ThumbnailParametergetParam()Returns theThumbnailParameterfor thisThumbnailTask, used when performing a thumbnail generation operation.java.io.InputStreamgetSource()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.InputStream,java.io.OutputStream> task
TheSourceSinkThumbnailTaskused to perform the task.
-
-
Constructor Detail
-
StreamThumbnailTask
public StreamThumbnailTask(ThumbnailParameter param, java.io.InputStream is, java.io.OutputStream os)
Creates aThumbnailTaskin which streamed image data from the specifiedInputStreamis output to a specifiedOutputStream, using the parameters provided in the specifiedThumbnailParameter.- Parameters:
param- The parameters to use to create the thumbnail.is- TheInputStreamfrom which to obtain image data.os- TheOutputStreamto send thumbnail data to.- 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.InputStream,java.io.OutputStream>- 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.InputStream,java.io.OutputStream>- 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.InputStream,java.io.OutputStream>- Returns:
- The parameters to use when generating thumbnails.
-
getSource
public java.io.InputStream getSource()
Description copied from class:ThumbnailTaskReturns the source from which the source image is retrieved or read.- Specified by:
getSourcein classThumbnailTask<java.io.InputStream,java.io.OutputStream>- Returns:
- The source.
-
getDestination
public java.io.OutputStream getDestination()
Description copied from class:ThumbnailTaskReturns the destination to which the thumbnail is stored or written.- Specified by:
getDestinationin classThumbnailTask<java.io.InputStream,java.io.OutputStream>- Returns:
- The destination.
-
-