Class ImageEncoderJPG
java.lang.Object
one.jpro.platform.image.manager.encoder.ImageEncoderJPG
- All Implemented Interfaces:
ImageEncoder,JsonConvertible
An implementation of ImageEncoder for encoding images in JPG format.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ImageEncoderJPG(double quality) Constructor with specified quality. -
Method Summary
Modifier and TypeMethodDescriptionGets the file extension for this encoder, which is "jpg".voidsaveImage(BufferedImage image, File target) Save the provided image to the specified file in JPG format.org.json.JSONObjecttoJSON()Converts the object to a JSON representation.
-
Constructor Details
-
ImageEncoderJPG
public ImageEncoderJPG()Default constructor. Initializes with a default quality of 0.80. -
ImageEncoderJPG
public ImageEncoderJPG(double quality) Constructor with specified quality.- Parameters:
quality- The quality factor for encoding, a value between 0.0 and 1.0.- Throws:
IllegalArgumentException- If the provided quality is not between 0.0 and 1.0.
-
-
Method Details
-
saveImage
Save the provided image to the specified file in JPG format. Note: The current implementation doesn't consider the quality settings due to Java's ImageIO limitations.- Specified by:
saveImagein interfaceImageEncoder- Parameters:
image- The image to be saved.target- The target file where the image will be saved.- Throws:
ImageEncoderException- If there's an error while saving the image.
-
getFileExtension
Gets the file extension for this encoder, which is "jpg".- Specified by:
getFileExtensionin interfaceImageEncoder- Returns:
- The file extension string.
-
toJSON
public org.json.JSONObject toJSON()Description copied from interface:JsonConvertibleConverts the object to a JSON representation.- Specified by:
toJSONin interfaceJsonConvertible- Returns:
- A JSONObject representing the object.
-