QImageWriter and EXIF
-
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? -
Hi,
There was at some point the QExifImageHeader class that might be of interest.
-
Hi,
There was at some point the QExifImageHeader class that might be of interest.
@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.
-
@samdol what about this EXIF helper code?
-
Might be, I can't confirm, I don't have images containing such data to test.
-
@samdol what about this EXIF helper code?
@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. -
@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 -
@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@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
-
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.
-
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.
-
@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
-
@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
-
@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.htmlEXIF_TAG_USER_COMMENT
EXIF_TAG_GPS_VERSION_ID
EXIF_TAG_GPS_ALTITUDE_REF:might work ?
-
@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
@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?