Skip to main content
Interwork Corporation
IDR Solutions Product Support Portal
PDF開発用語集 モードの切替 ダーク/ライト/自動 モードの切替 ダーク/ライト/自動 モードの切替 ダーク/ライト/自動

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