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
QtWS25 Last Chance

QImageWriter and EXIF

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 6 Posters 6.1k Views
  • 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.
  • S Offline
    S Offline
    samdol
    wrote on 11 Oct 2017, 22:12 last edited by
    #1

    Hi,

    I used QImageReader to read image from file and QImageWriter to save imge to file. The issue is that when I save image to file using QImageWriter, it looses EXI
    F information of image. Is there any way in Qt I don't loose EXIF information when I save image to file?

    1 Reply Last reply
    1
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 11 Oct 2017, 22:34 last edited by
      #2

      Hi,

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

      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 12 Oct 2017, 09:07
      1
      • S SGaist
        11 Oct 2017, 22:34

        Hi,

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

        S Offline
        S Offline
        samdol
        wrote on 12 Oct 2017, 09:07 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
        • P Offline
          P Offline
          Pablo J. Rogina
          wrote on 12 Oct 2017, 17:44 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 13 Oct 2017, 01:08
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 12 Oct 2017, 19:36 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 13 Oct 2017, 01:19
            0
            • P Pablo J. Rogina
              12 Oct 2017, 17:44

              @samdol what about this EXIF helper code?

              S Offline
              S Offline
              samdol
              wrote on 13 Oct 2017, 01:08 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
              • S SGaist
                12 Oct 2017, 19:36

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

                S Offline
                S Offline
                samdol
                wrote on 13 Oct 2017, 01:19 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 17 Dec 2018, 16:13
                0
                • S samdol
                  13 Oct 2017, 01:19

                  @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 17 Dec 2018, 16:13 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
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 17 Dec 2018, 20:37 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 18 Dec 2018, 08:17
                    0
                    • S SGaist
                      17 Dec 2018, 20:37

                      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 18 Dec 2018, 08:17 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 18 Dec 2018, 08:36
                      0
                      • L Luisa
                        18 Dec 2018, 08:17

                        @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 18 Dec 2018, 08:36 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 18 Dec 2018, 15:04
                        2
                        • jsulmJ jsulm
                          18 Dec 2018, 08:36

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

                          L Offline
                          L Offline
                          Luisa
                          wrote on 18 Dec 2018, 15:04 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 P 2 Replies Last reply 18 Dec 2018, 15:33
                          0
                          • L Luisa
                            18 Dec 2018, 15:04

                            @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 18 Dec 2018, 15:33 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 18 Dec 2018, 15:42
                            0
                            • jsulmJ jsulm
                              18 Dec 2018, 15:33

                              @Luisa Sorry, I don't have any examples

                              L Offline
                              L Offline
                              Luisa
                              wrote on 18 Dec 2018, 15:42 last edited by
                              #14

                              @jsulm :-(

                              mrjjM 1 Reply Last reply 18 Dec 2018, 15:49
                              0
                              • L Luisa
                                18 Dec 2018, 15:42

                                @jsulm :-(

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 18 Dec 2018, 15:49 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
                                  18 Dec 2018, 15:04

                                  @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

                                  P Offline
                                  P Offline
                                  Pablo J. Rogina
                                  wrote on 19 Dec 2018, 12:53 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