Class ImageUtils

java.lang.Object
org.aesh.terminal.image.ImageUtils

public final class ImageUtils extends Object
Utility class for image format detection and conversion.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getFormat(byte[] data)
    Get the image format name based on magic bytes.
    static boolean
    isGif(byte[] data)
    Check if the image data is in GIF format.
    static boolean
    isJpeg(byte[] data)
    Check if the image data is in JPEG format.
    static boolean
    isPng(byte[] data)
    Check if the image data is in PNG format.
    static byte[]
    toPng(byte[] data)
    Convert image data to PNG format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static byte[] toPng(byte[] data) throws IOException
      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

      public static String getFormat(byte[] data)
      Get the image format name based on magic bytes.
      Parameters:
      data - the image data
      Returns:
      format name ("PNG", "JPEG", "GIF", or "UNKNOWN")