I am using Apache tika library to extract metadata for files like width and height. Here is my code snippet
public void fileMetadata(final File file) {
FileMetadataModel fileMetaData = null;
var context = new ParseContext();
var parser = new AutoDetectParser();
var bodyContentHandler = new BodyContentHandler();
var metadata = new Metadata();
try (final var openInputStream = FileUtils.openInputStream(file)) {
parser.parse(openInputStream, bodyContentHandler, metadata, context);
// metadata extration
..........
} catch (Exception e) {
//
}
}
Maven dependencies
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers-standard-package</artifactId>
<version>2.3.0</version>
<exclusions>
<exclusion>
<artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId>
</exclusion>
</exclusions>
</dependency>
I see for SVG file it doesn't give image height and width. Is there any way to get it through Apache tika?