|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.coobird.thumbnailator.tasks.io.AbstractImageSink<File> net.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 AbstractImageSink.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 detination file of the thumbnail image. |
String |
preferredOutputFormatName()
Returns the output format to use from information provided for the output image. |
void |
write(BufferedImage img)
Writes the resulting image to a file. |
Methods inherited from class net.coobird.thumbnailator.tasks.io.AbstractImageSink |
---|
setOutputFormatName, setThumbnailParameter |
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
AbstractImageSink.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
AbstractImageSink.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
AbstractImageSink.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
AbstractImageSink.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>
preferredOutputFormatName
in class AbstractImageSink<File>
public void write(BufferedImage img) throws IOException
write
in interface ImageSink<File>
write
in class AbstractImageSink<File>
img
- The image to write.
UnsupportedFormatException
- When an unsupported format has been
specified by the
AbstractImageSink.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.)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |