4

I am using the excellent metadata-extractor library. It is very good for retrieving detailed metadata from many different image formats.

However, for a project i am only interested in extracting "common image metadata" (like width and height). In this use case the API is quiet verbose AFIAK.

I am looking for a convenience API like:

final MetadataWrapper md = MetadataWrapper.readMetadata(file);
FileType type = md.getFileType();
int width = md.getWidth();
int height = md.getHeight();

Any suggestions?

rmuller
  • 12,062
  • 4
  • 64
  • 92

2 Answers2

5

If you know exactly what metadata you need, you're probably best off writing a small wrapper around metadata-extractor that checks for specific types of directory, and tests them for given tags.

The concept of 'width' can be specified in many different tags. metadata-extractor doesn't provide any abstraction over these, though there is an issue discussing the idea. It'll be tricky to implement robustly.

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
  • Thanks! An up vote for the link, really helpful discussion and indeed where I am looking for. – rmuller Aug 18 '15 at 18:20
  • I think a general approach to retrieving common metadata like width and height would be great. But after reading the discussion (link from above) I understand the problem. The only question is whether you can do it better yourself. I now have several checks in my application for DirectoryType and then fetch the metadata I want. This is always a bit cumbersome, since one always overlooks any exotics such as HEIC images and then subsequently incorporated. – Ben May 23 '23 at 14:10
0

Why don't you give the Java7 BufferedImage a try? It contains the convenient methods getHeight, getWidth and getType.

More info here: BufferedImage

s.ijpma
  • 930
  • 1
  • 11
  • 23
  • 1
    Because I need to process a large number of large files (so performance is important) and (most important) metadata-extractor supports much more image formats – rmuller Aug 18 '15 at 11:27
  • Point taken, extended & improved my answer. – s.ijpma Aug 18 '15 at 13:38