Link
Skip to main content

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();
}

Get started with JDeli in 3 steps

  1. Fill in the form to download the trial jar →
  2. Copy the code snippets as instructed on the next page
  3. Build your solution using our docs

Learn more about JDeli

Start Your Free Trial