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

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