Apache Tikaを使用して画像形式を検出する方法
JDeliは、画像形式を検出するためのApache Tikaプラグインを提供しています。シンプルなdetect()メソッドは、MediaType
を返し、これにはMIMEタイプ
として画像形式が含まれています。
注意: この機能を使用するには、クラスパスにApache Tikaが必要です。Tikaはこちら からダウンロードできます。
try {
final ImageDetector detector = new ImageDetector();
final MediaType mimeType = detector.detect(TikaInputStream.get(Paths.get("file.img")), null);
} catch (final IOException e) {
e.printStackTrace();
}
