Link

How to Detect Image Format Using Apache Tika

JDeli provides an Apache Tika plugin to detect image formats. The simple detect() method returns a MediaType which contains the image format as a MIME Type.

Note: you will need Apache Tika on your classpath to use this feature. You can download Tika here.

Example Usage

try {
    final ImageDetector detector = new ImageDetector();
    final MediaType mimeType = detector.detect(TikaInputStream.get(Paths.get("file.img")), null);
} catch (final IOException e) {
    e.printStackTrace();
}

Why JDeli?

  • Support image formats such as AVIF, HEIC and JPEG XL (AVIF soon) that are not supported in Java.
  • Process images up to 3x faster than ImageIO and alternative Java image libraries.
  • Prevent JVM crashes caused by native code in other image libraries such as ImageIO.
  • Handle JPEG, PNG, TIFF image file formats fully in Java.
  • Keep your Image files secure as JDeli makes no calls to any external system or third party library.

Start Your Free Trial