Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QImageWriter and EXIF
Forum Updated to NodeBB v4.3 + New Features

QImageWriter and EXIF

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 6 Posters 6.3k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS SGaist

    Hi,

    There was at some point the QExifImageHeader class that might be of interest.

    S Offline
    S Offline
    samdol
    wrote on last edited by
    #3

    @SGaist
    Thanks, I have checked it, but there seems some bug for Gps info. For example, when I run following code, I think exif values should not change.

        QExifImageHeader header;
        header.loadFromJpeg("C:/myfile.jpg");
        QExifValue value_GpsLatitude = header.value(QExifImageHeader::GpsLatitude);
        QExifValue value_ImageWidth = header.value(QExifImageHeader::ImageWidth);
        QExifValue value_Make = header.value(QExifImageHeader::Make);
        QExifValue value_Model = header.value(QExifImageHeader::Model);
        header.setValue(QExifImageHeader::GpsLatitude, value_GpsLatitude);
        header.setValue(QExifImageHeader::ImageWidth, value_ImageWidth);
        header.setValue(QExifImageHeader::Make, value_Make);
        header.setValue(QExifImageHeader::Model, value_Model);
        header.saveToJpeg("C:/myfile.jpg");
    

    But when I run it, GpsLatitude value has changed. Do you think it is a bug?
    And how can I read GpsLatitude?
    When I run the following,

       qDebug()<<"laa: "<< QString::number(value_GpsLatitude.toRational().first)+"/"+QString::number(value_GpsLatitude.toRational().second);
    

    I always get "0/0" which is not correct.

    1 Reply Last reply
    0
    • Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #4

      @samdol what about this EXIF helper code?

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      S 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #5

        Might be, I can't confirm, I don't have images containing such data to test.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply
        0
        • Pablo J. RoginaP Pablo J. Rogina

          @samdol what about this EXIF helper code?

          S Offline
          S Offline
          samdol
          wrote on last edited by samdol
          #6

          @Pablo-J.-Rogina
          Thank you, I used it before. but it only reads exif information. Because I want to preserve EXIF after save image, I need a method to read/write exif.

          1 Reply Last reply
          0
          • SGaistS SGaist

            Might be, I can't confirm, I don't have images containing such data to test.

            S Offline
            S Offline
            samdol
            wrote on last edited by samdol
            #7

            @SGaist
            I found that Reading Gps information should be like this,

              qDebug()<<"laa: "<< QString::number(value_GpsLatitude.toRationalVector().at(0).first)+"/"+QString::number(value_GpsLatitude.toRationalVector().at(0).second);
              qDebug()<<"laa: "<< QString::number(value_GpsLatitude.toRationalVector().at(1).first)+"/"+QString::number(value_GpsLatitude.toRationalVector().at(1).second);
              qDebug()<<"laa: "<< QString::number(value_GpsLatitude.toRationalVector().at(2).first)+"/"+QString::number(value_GpsLatitude.toRationalVector().at(2).second);
            

            But I still don't understand why it changes Gps value after

            header.saveToJpeg("C:/myfile.jpg");  
            

            It changes even without

            header.setValue(QExifImageHeader::GpsLatitude, value_GpsLatitude);
            

            It seems a bug.
            You may get test jpg file with gps_tag from here

            L 1 Reply Last reply
            0
            • S samdol

              @SGaist
              I found that Reading Gps information should be like this,

                qDebug()<<"laa: "<< QString::number(value_GpsLatitude.toRationalVector().at(0).first)+"/"+QString::number(value_GpsLatitude.toRationalVector().at(0).second);
                qDebug()<<"laa: "<< QString::number(value_GpsLatitude.toRationalVector().at(1).first)+"/"+QString::number(value_GpsLatitude.toRationalVector().at(1).second);
                qDebug()<<"laa: "<< QString::number(value_GpsLatitude.toRationalVector().at(2).first)+"/"+QString::number(value_GpsLatitude.toRationalVector().at(2).second);
              

              But I still don't understand why it changes Gps value after

              header.saveToJpeg("C:/myfile.jpg");  
              

              It changes even without

              header.setValue(QExifImageHeader::GpsLatitude, value_GpsLatitude);
              

              It seems a bug.
              You may get test jpg file with gps_tag from here

              L Offline
              L Offline
              Luisa
              wrote on last edited by
              #8

              @samdol I have the same problem.

              If I load metadata and then I save without changing anything I read incorrect value.
              Have you find a solution?

              QExifImageHeader * source = new QExifImageHeader();
              QExifValue *vale;
              source->loadFromJpeg(filedest);
              source->saveToJpeg(filedest);
              QExifImageHeader * dest = new QExifImageHeader();
              dest->loadFromJpeg(filedest);
              

              Thanke you for your help

              Luisa

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                IIRC, when I took a look at it, there was an issue with handling some of the tags. I can't remember exactly what it was.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                L 1 Reply Last reply
                0
                • SGaistS SGaist

                  IIRC, when I took a look at it, there was an issue with handling some of the tags. I can't remember exactly what it was.

                  L Offline
                  L Offline
                  Luisa
                  wrote on last edited by
                  #10

                  @SGaist Do you know a library that I could use to read / write exif files? I need to cross compile it for a system embedded. I tried exiv2 with poor results

                  jsulmJ 1 Reply Last reply
                  0
                  • L Luisa

                    @SGaist Do you know a library that I could use to read / write exif files? I need to cross compile it for a system embedded. I tried exiv2 with poor results

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @Luisa https://github.com/libexif/libexif

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    L 1 Reply Last reply
                    2
                    • jsulmJ jsulm

                      @Luisa https://github.com/libexif/libexif

                      L Offline
                      L Offline
                      Luisa
                      wrote on last edited by
                      #12

                      @jsulm I try to use this library but I have some problem with GPSAltitude and so on...

                      Have you some example to write GPS param into file jpg?
                      and Usercomment field?

                      Thank you so much

                      jsulmJ Pablo J. RoginaP 2 Replies Last reply
                      0
                      • L Luisa

                        @jsulm I try to use this library but I have some problem with GPSAltitude and so on...

                        Have you some example to write GPS param into file jpg?
                        and Usercomment field?

                        Thank you so much

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        @Luisa Sorry, I don't have any examples

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        L 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @Luisa Sorry, I don't have any examples

                          L Offline
                          L Offline
                          Luisa
                          wrote on last edited by
                          #14

                          @jsulm :-(

                          mrjjM 1 Reply Last reply
                          0
                          • L Luisa

                            @jsulm :-(

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            @Luisa
                            Hi
                            I was wondering if the sample
                            https://github.com/libexif/libexif/blob/master/contrib/examples/write-exif.c
                            combined with the info from
                            https://libexif.github.io/internals/exif-entry_8c-source.html

                            EXIF_TAG_USER_COMMENT
                            EXIF_TAG_GPS_VERSION_ID
                            EXIF_TAG_GPS_ALTITUDE_REF:

                            might work ?

                            1 Reply Last reply
                            2
                            • L Luisa

                              @jsulm I try to use this library but I have some problem with GPSAltitude and so on...

                              Have you some example to write GPS param into file jpg?
                              and Usercomment field?

                              Thank you so much

                              Pablo J. RoginaP Offline
                              Pablo J. RoginaP Offline
                              Pablo J. Rogina
                              wrote on last edited by
                              #16

                              @Luisa said in QImageWriter and EXIF:

                              I try to use this library but I have some problem with GPSAltitude and so on...

                              Could you please show the issue?

                              Upvote the answer(s) that helped you solve the issue
                              Use "Topic Tools" button to mark your post as Solved
                              Add screenshots via postimage.org
                              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                              1 Reply Last reply
                              2

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved