Project

General

Profile

How correctly write GPS data

Added by Anonymous about 9 years ago

For writing GPS data I use:

Exiv2::RationalValue::AutoPtr rv(new Exiv2::RationalValue);
rv->read("5/3 1/3 1/4");
Exiv2::ExifKey key = Exiv2::ExifKey("Exif.GPSInfo.GPSLongitude");
exifData.add(key, rv.get());
image->setExifData(exifData);
image->writeMetadata();

But if I read this data:

Exiv2::ExifMetadata::iterator itL = exifData.findKey(Exiv2::ExifKey("Exif.GPSInfo.GPSLongitude"));
out << itL->value().toFloat(0) << "° " << itL->value().toFloat(1) << "' " << itL->value().toFloat(2) << "\"";

I get previous GPS data
When I run my program again displayed GPS value which I write.

So, how doing somуthing like fflush, or where is my mistake?


Replies (11)

RE: How correctly write GPS data - Added by Andreas Huggel about 9 years ago

This looks ok, setExifData and writeMetadata is all that is required. If you can you reproduce the problem in a small sample program please post it here.

Andreas

RE: How correctly write GPS data - Added by Anonymous about 9 years ago

Now I use:
char scratchBuf100;
long int deg, min;
exifData["Exif.GPSInfo.GPSLongitudeRef"] = (longitude < 0 ) ? "W" : "E";
deg = (int)floor(fabs(longitude)); // Slice off after decimal.
min = (int)floor((fabs(longitude) - floor(fabs(longitude))) * 60000000);
snprintf(scratchBuf, 100, "%ld/1 %ld/1000000 0/1", deg, min);
exifData["Exif.GPSInfo.GPSLongitude"] = scratchBuf;

image->setExifData(exifData);
image->writeMetadata();
and it work perfect.

RE: How correctly write GPS data - Added by Anonymous about 9 years ago

But, I have run time error when try:
image->setExifData(exifData);
in PNG image in Windows(with JPG image it work good).
In Linux all work perfect.
So, why is this happening.

RE: How correctly write GPS data - Added by Robin Mills about 9 years ago

Please send us:
1 a sample image
2 reduce your code to the minimum for us to reproduce
3 which version and build of exiv2 are you using
4 how did you obtain the libraries (downloaded or did you build it)
5 if you build it (on Windows). How? DevStudio+version, MinGW, Cygwin?

RE: How correctly write GPS data - Added by Anonymous about 9 years ago

1) sample image: ico.png (I test a lot of PNG image but the result is the same)
2) main.cpp
3) Exiv2 v0.21.1 Source
4) I build libraries
5) I buil libraries on Linux for Windows using i586-mingw32

ico.png (369 KB) ico.png
main.cpp (2.66 KB) main.cpp

RE: How correctly write GPS data - Added by Anonymous about 9 years ago

I found something, an interesting, incomprehensible for me:
GPS tag recorded in a Linux into PNG-image is visible in my and other(Gwenview, digiKam) viewer.
But in Windows in my and other viewer this tag(writed in Linux) is invisible. ;)

RE: How correctly write GPS data - Added by Robin Mills about 9 years ago

Aleksandr

I attach a photo of Adobe's building (where I used to work). I geotagged this with exiv2 (using the python pyexiv2 wrapper). The geotagging of this photo seems works correctly for me on various applications on Windows/Mac/Linux. Could you inspect this with your applications on Windows/Linux.

I tried to build exiv2 0.21.1 on Cygwin last night to reproduce your issues and was surprised to encounter a linking issue. I'm sure this has something to do with my Cygwin setup on my laptop (it has always build easily in the past). I probably won't have time today to try on a different machine. So, I'll look at your code on Saturday afternoon (in California) and get back to you.

Robin

Adobe.jpg (3.85 MB) Adobe.jpg Geotagged image of Adobe's building in San Jose, California.

RE: How correctly write GPS data - Added by Anonymous about 9 years ago

I build sample addmoddel.cpp in Windows on gcc.
I got(1.jpg):
1) my png image -- ico.png
2) image create in Adobe Photoshop -- Untitled-1.png
3) jpg image -- 05.JPG

1.jpg (205 KB) 1.jpg

RE: How correctly write GPS data - Added by Robin Mills about 9 years ago

Sasha

I'm sorry. I can't be of any assistance to you. I've tried on 3 different Windows machine on Saturday/Sunday/today to build exiv2 with MinGW. I'm unable to get a successful build. I don't know why this isn't working as it has been fine in the past. I'm quite certain that the issues are in the setup of the Windows machine (and not the exiv2 code).\

I cannot provide support for MinGW.

RE: How correctly write GPS data - Added by Anonymous about 9 years ago

I had the same problem with building exiv2 library in Windows. But I build library in Linux with i586-mingw32 and use obtained dll in Windows (I can send you this dll).

It maybe not necessary for me to record exif data into PNG-image. But I can't catch exception (only in Windows) when I try to write EXIF data into not supported type of image.
Maybe you know, why this is happening?

RE: How correctly write GPS data - Added by Andreas Huggel about 9 years ago

I can't catch exception (only in Windows) when I try to write EXIF data into not supported type of image.
Maybe you know, why this is happening?

We've seen this before in connection with the symbol visibility feature. Make sure you use the same settings for the DLL and program that uses it.
See issue #523 and http://gcc.gnu.org/wiki/Visibility esp. the section "Problems with C++ exceptions"

Andreas

    (1-11/11)