|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.coobird.thumbnailator.tasks.io.FileImageSink
public class FileImageSink
An ImageSink
which writes the resulting thumbnail to a file.
Under certain circumstances, the destination file can change in the course of processing.
This can occur in cases where the file extension does not
match the output format set by the setOutputFormatName(String)
method. In this case, the file name will have a file extension corresponding
to the output format set in the above method to be appended to the file
name originally provided when instantiating the FileImageSink
object.
Constructor Summary | |
---|---|
FileImageSink(File destinationFile)
Instantiates a FileImageSink with the file to which the thumbnail
should be written to. |
|
FileImageSink(File destinationFile,
boolean allowOverwrite)
Instantiates a FileImageSink with the file to which the thumbnail
should be written to. |
|
FileImageSink(String destinationFilePath)
Instantiates a FileImageSink with the file to which the thumbnail
should be written to. |
|
FileImageSink(String destinationFilePath,
boolean allowOverwrite)
Instantiates a FileImageSink with the file to which the thumbnail
should be written to. |
Method Summary | |
---|---|
File |
getSink()
Returns the destination file of the thumbnail image. |
String |
preferredOutputFormatName()
Returns the output format to use from information provided for the output image. |
void |
setOutputFormatName(String format)
Sets the output format of the resulting image. |
void |
setThumbnailParameter(ThumbnailParameter param)
Sets the ThumbnailParameter from which to retrieve parameters
to use when storing the image. |
void |
write(BufferedImage img)
Writes the resulting image to a file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileImageSink(File destinationFile)
FileImageSink
with the file to which the thumbnail
should be written to.
The output format to use will be determined from the file extension.
If another format should be used, then the
setOutputFormatName(String)
should be called with the desired
output format name.
When the destination file exists, then this FileImageSink
will
overwrite the existing file.
destinationFile
- The destination file.
NullPointerException
- If the specified file is null
.public FileImageSink(File destinationFile, boolean allowOverwrite)
FileImageSink
with the file to which the thumbnail
should be written to.
The output format to use will be determined from the file extension.
If another format should be used, then the
setOutputFormatName(String)
should be called with the desired
output format name.
destinationFile
- The destination file.allowOverwrite
- Whether or not the FileImageSink
should overwrite the destination file if
it already exists.
NullPointerException
- If the specified file is null
.public FileImageSink(String destinationFilePath)
FileImageSink
with the file to which the thumbnail
should be written to.
The output format to use will be determined from the file extension.
If another format should be used, then the
setOutputFormatName(String)
should be called with the desired
output format name.
When the destination file exists, then this FileImageSink
will
overwrite the existing file.
destinationFilePath
- The destination file path.
NullPointerException
- If the specified file path is null
.public FileImageSink(String destinationFilePath, boolean allowOverwrite)
FileImageSink
with the file to which the thumbnail
should be written to.
The output format to use will be determined from the file extension.
If another format should be used, then the
setOutputFormatName(String)
should be called with the desired
output format name.
destinationFilePath
- The destination file path.allowOverwrite
- Whether or not the FileImageSink
should overwrite the destination file if
it already exists.
NullPointerException
- If the specified file path is null
.Method Detail |
---|
public String preferredOutputFormatName()
ImageSink
If the output format cannot be determined, then
ThumbnailParameter.ORIGINAL_FORMAT
should be returned.
preferredOutputFormatName
in interface ImageSink<File>
public void write(BufferedImage img) throws IOException
write
in interface ImageSink<File>
img
- The image to write.
UnsupportedFormatException
- When an unsupported format has been
specified by the
setOutputFormatName(String)
method, or if the output format
has not been set and cannot be
determined from the file name.
IOException
- When a problem occurs while writing
the image.
NullPointerException
- If the image is null
.
IllegalArgumentException
- If this FileImageSink
does
not permit overwriting the
destination file and the destination
file already exists.public File getSink()
If the final destination of the thumbnail changes in the course of writing the thumbnail. (For example, if the file extension for the given destination did not match the destination file format, then the correct file extension could be appended.)
getSink
in interface ImageSink<File>
public void setOutputFormatName(String format)
ImageSink
For ImageSink
s which stores raw images, the format name specified
by this method may be ignored.
setOutputFormatName
in interface ImageSink<File>
format
- File format with which to store the image.public void setThumbnailParameter(ThumbnailParameter param)
ImageSink
ThumbnailParameter
from which to retrieve parameters
to use when storing the image.
setThumbnailParameter
in interface ImageSink<File>
param
- The ThumbnailParameter
with image
writing parameters.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |