Read exif metadata of images in Qt

前端 未结 3 1147
难免孤独
难免孤独 2020-12-22 04:36

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 re

相关标签:
3条回答
  • 2020-12-22 05:13

    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/

    0 讨论(0)
  • 2020-12-22 05:17

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

    0 讨论(0)
  • 2020-12-22 05:22

    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;
    }
    
    0 讨论(0)
提交回复
热议问题