S B
S B

Reputation: 8394

Read exif metadata of images in Qt

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

Upvotes: 4

Views: 10015

Answers (2)

olned64
olned64

Reputation: 41

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

Upvotes: 2

Dmitry Sazonov
Dmitry Sazonov

Reputation: 9014

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

Upvotes: 1

Related Questions