Package org.aesh.terminal.image
Class ImageUtils
java.lang.Object
org.aesh.terminal.image.ImageUtils
Utility class for image format detection and conversion.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetFormat(byte[] data) Get the image format name based on magic bytes.static booleanisGif(byte[] data) Check if the image data is in GIF format.static booleanisJpeg(byte[] data) Check if the image data is in JPEG format.static booleanisPng(byte[] data) Check if the image data is in PNG format.static byte[]toPng(byte[] data) Convert image data to PNG format.
-
Method Details
-
isPng
public static boolean isPng(byte[] data) Check if the image data is in PNG format.- Parameters:
data- the image data- Returns:
- true if the data starts with PNG signature
-
isJpeg
public static boolean isJpeg(byte[] data) Check if the image data is in JPEG format.- Parameters:
data- the image data- Returns:
- true if the data starts with JPEG signature
-
isGif
public static boolean isGif(byte[] data) Check if the image data is in GIF format.- Parameters:
data- the image data- Returns:
- true if the data starts with GIF signature
-
toPng
Convert image data to PNG format. If the data is already PNG, it is returned as-is. Otherwise, the image is decoded and re-encoded as PNG.- Parameters:
data- the image data (JPEG, PNG, GIF, BMP, etc.)- Returns:
- PNG encoded image data
- Throws:
IOException- if the image cannot be read or converted
-
getFormat
Get the image format name based on magic bytes.- Parameters:
data- the image data- Returns:
- format name ("PNG", "JPEG", "GIF", or "UNKNOWN")
-