java.lang.Object
org.miaixz.bus.extra.image.ImageWriter
- All Implemented Interfaces:
Flushable
Image writer wrapper.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidflush()static ImageWriterCreates an ImageWriter.static ImageWriterCreates an ImageWriter.setQuality(float quality) Sets the write quality.voidWrites the image in the format corresponding to the destination file's extension.voidwrite(OutputStream out) Writes the image.voidwrite(ImageOutputStream output) Writes the image to an output stream using anImageWriter.
-
Constructor Details
-
ImageWriter
Constructor.- Parameters:
image- TheImage.imageType- The image type (extension), ornullfor RGB mode (JPG).
-
-
Method Details
-
of
Creates an ImageWriter.- Parameters:
image- The image.imageType- The image type (extension), ornullfor RGB mode (JPG).backgroundColor- The background colorColor, ornullfor black or transparent.- Returns:
- An
ImageWriter.
-
of
Creates an ImageWriter.- Parameters:
image- The image.imageType- The image type (extension), ornullfor RGB mode (JPG).- Returns:
- An
ImageWriter.
-
setQuality
Sets the write quality. A value between 0 and 1 (exclusive) indicates a compression ratio; other values indicate no compression.- Parameters:
quality- The write quality, a value between 0 and 1 (exclusive) for compression.- Returns:
- this
-
write
Writes the image. This method does not close the stream.- Parameters:
out- The target output stream.- Throws:
org.miaixz.bus.core.lang.exception.InternalException- if an I/O error occurs.
-
write
Writes the image in the format corresponding to the destination file's extension.- Parameters:
destFile- The destination file.- Throws:
org.miaixz.bus.core.lang.exception.InternalException- if an I/O error occurs.
-
write
Writes the image to an output stream using anImageWriter.- Parameters:
output- TheImageOutputStreamto write to (not null).
-
flush
public void flush()
-