[Qt-interest] New image metadata parser based on the Qt

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Wed Jan 26 11:38:20 CET 2011


On 2011-01-25 Sami Sami Maisniemi wrote:

> Hi all,
> 
> I have created a new image metadata parser with the Qt and I have released it
> under the LGPL license. 

Hey, that's very nice! I might need it in the future for my own project for quickly reading the image dimensions, without reading the entire JPEG :)

Do you know by any chance "jhead" (http://www.sentex.net/~mwandel/jhead/ , apparently a C port from the Java "Metadata Extractor" at http://www.drewnoakes.com/code/exif/)? And do you know http://www.exiv2.org/ (C++)?

How does or will your library compare to these libraries with respect to supported tags? For instance, I did not see methods yet in your library for extracting GPS data - any plans for that?

What I like about your library it still seems very "compact" (with only 3 relevant source files so far), and I am looking for an "all day quick and easy" meta data extraction of common data like F number, focal length etc. - and maybe also GPS data later on - basically the EXIF tags.

But I am not so much interested in "Makernotes" support for now (which is maker dependent, AFAIK). So your library looks quite promising (I know EXIV2 a little bit, haven't looked at "jhead" yet, but was about to use that one).

So your project looks very interesting as well, will try it with my "Pentax K5" images soon ;)

> - QImageMetaData.h
> - QImageMetaData.cpp
> - QImageMetaDataRational.h

I very quickly looked at the code, I found the #width() method which supposedly returns the image witdh in pixels, but I did not find a height method (but a length() method instead - what does that return?).

Then on http://www.gitorious.org/qimagemetadata/qimagemetadata/blobs/master/QImageMetaData.h#line1221 onwards there are methods pixelXDimension and pixelYDimension (which are probably the methods I am looking after), but their documentation seems to be outdated: http://www.gitorious.org/qimagemetadata/qimagemetadata/blobs/master/QImageMetaData.h#line1232 talks about "Method: validheight" (which should probably really be pixelYDimenstion instead) and refers to ("See also") a method height(), but that method does not seem to exist. ;)

Also I would refrain from #including all Qt headers with

#include <QtGui>

That unnecessarily increases compile time (since ALL Qt headers from QtCore and QtGui are included and need to be parsed!). Convenient for quick "proof of concept"/example applications, but for "real world" applications I would like to see

// only include what is really necessary, use forward declarations to shorten
// compile time even more!
#include <QtCore/QString>
#include <QtCore/QList>
#include <QtGui/QImage>

class QFile;
class QDir;
...
Etc.

Also my personal preference would be to pass along references instead of pointers. Passing along a pointer for me has the implicit meaning that this parameter is either optional or it HAS to be allocated on the heap, and the method takes ownership over that object.

So for instance: http://www.gitorious.org/qimagemetadata/qimagemetadata/blobs/master/QImageMetaData.h#line1525:

  void readRational(QFile* file, ...);

I don't think this method makes much sence without passing along a valid QFile, so I would do instead:

  Void readRational(QFile &file, ...);

Also has the advantage that within the method you don't need to worry about null pointers ;)

And while we're at it, why not pass along a QIODevice instead? Like this the application could also read meta data for image data already in memory, in a QByteArray, for instance :) It is also not clear whether the application is responsible for opening that QIODevice or whether your method takes care of opening/closing the device (should be documented ;)




So did I understand you correctly that you would like to see this included in the Qt API? :) That would be nice, but maybe that code should go into a separate module like "QtImageProcessing" or so, since reading "image meta data" is a pretty specialised domain. However I'd be happy to see something like this included in the Qt API :)


Great stuff! Keep it going! :) Thanks for sharing!
  Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22





More information about the Qt-interest-old mailing list