4

In my Qt app I want to read exif data of images. QImage or QPixmap don't seem to provide such hooks.

Is there any API in Qt that allows reading exif without using external libraries like libexif?

EDIT: This is a duplicate of this

Community
  • 1
  • 1
S B
  • 8,134
  • 10
  • 54
  • 108
  • Duplicate of http://stackoverflow.com/questions/4105534/what-exif-lib-can-i-use-from-a-qt-program-on-embedded-linux?rq=1 –  Feb 28 '13 at 06:15

3 Answers3

2

For me, the best choice was easyexif by Mayank Lahiri. You only need to add two files exif.cpp and exif.h to your project.

int main(int argc, char *argv[])
{
    for (int i=1; i<argc; ++i){
        QFile file(argv[i]);
        if (file.open(QIODevice::ReadOnly)){
            QByteArray data = file.readAll();
            easyexif::EXIFInfo info;
            if (int code = info.parseFrom((unsigned char *)data.data(), data.size())){
                qDebug() << "Error parsing EXIF: code " << code;
                continue;
            }
            qDebug() << "Camera model         : " << info.Model.c_str();
            qDebug() << "Original date/time   : " << info.DateTimeOriginal.c_str();
        } else
            qDebug() << "Can't open file:" << argv[i];           
    }

    return 0;
}
olned64
  • 41
  • 1
  • 5
1

Try QExifImageHeader from qt extended framework. qtextended.org is not available for me? but you may search for other download mirrows.

Dmitry Sazonov
  • 8,801
  • 1
  • 35
  • 61
1

QImageReader has a method named transformation() which is introduced in version 5.5, first you should try that.

You can also check the following link to see how it's done using Windows GDI in Qt, http://amin-ahmadi.com/2015/12/17/how-to-read-image-orientation-in-qt-using-stored-exif/

Amin
  • 25
  • 5