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

Sami Maisniemi sami.maisniemi at katelabs.com
Wed Jan 26 23:24:12 CET 2011


On Jan 26, 2011, at 12:38 PM, <Oliver.Knoll at comit.ch> wrote:

> 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++)?

I was not aware of jhead, but it seems that it supports only JPEG images. I was aware of Exiv2, but it is released under GPL and therefore it is not applicable, because it cannot be used for propietary software. I wanted to release the source code under LGPL, because Qt has been released under LGPL.

> 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?

The target is to support all the tags of TIFF and EXIF standards including GPS data in the near future. Very likely all the tags are supported already in the spring. Also XMP and IPTC metadata will be supported, but I cannot give any kind of schedule yet.

> 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.

Thanks, my intention is to keep everything as simple as possible and I intend to keep the file count as minimal as possible.

> 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).

Could you be a little bit more specific?

> 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?).

If you find any bugs, please send the sample file and I will make unit tests for it. I have tested the source code quite a lot, but there seems to be quite remarkable differences between image processing applications.

The TIFF standard uses "length" instead of "height". Therefore method length() returns the height of the image. Very likely I am going to change the name of the method, because Qt uses "height" instead of "length".

> 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. ;)

Indeed the methods are a little bit confusing. The EXIF standard defines fields "pixelX/YDimension" which names are "valid image width/height". Very likely I am going to modify those methods as well.

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

I am going to take a look at these issues already in this weekend. Thanks for feedback, because this really helps me to improve the source code.

> 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 :)

I am sure that we will find one way or another how to merge the project into Qt in the future.

> Great stuff! Keep it going! :) Thanks for sharing!

Thanks for your comments and feedback :)

>  Oliver
> --
> Oliver Knoll
> Dipl. Informatik-Ing. ETH
> COMIT AG - ++41 79 520 95 22
> 
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest

Sami Maisniemi | Imaging Specialist | Kate Labs Ltd
www.katelabs.com | +358 400 114 070






More information about the Qt-interest-old mailing list