GNOME Bugzilla – Bug 377917
exif GPS data is removed from, when saving a jpeg with exif data
Last modified: 2008-01-15 13:15:04 UTC
Please describe the problem: When saving a jpeg file with exif data of which the original jpeg image contains GPS data in the exif information, then the exif GPS information is not saved to the output jpeg image. Steps to reproduce: 1. Open an jpeg image with exif informtion which include GPS data 2. do some modifications..... 3. Save again as a jpeg image with exif data Actual results: The GPS information has been removed from the exif data: [gert@apollo tmp]$ exiftool exif_gps_saved.jpg ExifTool Version Number : 6.56 File Name : exif_gps_saved.jpg File Size : 15 kB File Modification Date/Time : 2006:11:21 22:10:41 File Type : JPEG MIME Type : image/jpeg JFIF Version : 1.1 Resolution Unit : inches Modify Date : 2006:11:17 21:40:31 Date/Time Original : 2006:11:04 08:55:27 Create Date : 2006:11:04 08:55:27 User Comment : Egypte, Luxor - panorama foto van de Pyramide van Cheops in Gizeh Compression : JPEG (old-style) X Resolution : 72 Y Resolution : 72 Thumbnail Offset : 326 Thumbnail Length : 2460 Image Width : 400 Image Height : 169 Image Size : 400x169 Thumbnail Image : (Binary data 2460 bytes, use -b option to extract) [gert@apollo tmp]$ Expected results: The GPS data still being present: [gert@apollo tmp]$ exiftool exif_gps_original.jpg ExifTool Version Number : 6.56 File Name : exif_gps_original.jpg File Size : 15 kB File Modification Date/Time : 2006:11:21 22:01:58 File Type : JPEG MIME Type : image/jpeg Modify Date : 2006:11:17 21:40:31 Date/Time Original : 2006:11:04 08:55:27 Create Date : 2006:11:04 08:55:27 User Comment : Egypte, Luxor - panorama foto van de Pyramide van Cheops in Gizeh GPS Version ID : 0.0.2.2 GPS Latitude Ref : North GPS Latitude : 29 deg 58' 44.72" GPS Longitude Ref : East GPS Longitude : 31 deg 8' 2.72" GPS Altitude Ref : Above Sea Level GPS Altitude : 0 metres Compression : JPEG (old-style) X Resolution : 72 Y Resolution : 72 Thumbnail Offset : 465 Thumbnail Length : 2515 Image Width : 400 Image Height : 169 GPS Position : 29 deg 58' 44.72" N, 31 deg 8' 2.72" E Image Size : 400x169 Thumbnail Image : (Binary data 2515 bytes, use -b option to extract) [gert@apollo tmp]$ Does this happen every time? yes Other information:
Created attachment 76993 [details] jpeg file with GPS information in the exif data The jpeg file containing GPS information in the exif data, used to reproduce the bug.
Isn't it just one of the points of bug 56443?
GIMP should still preserve the EXIF data and as far as I know the JPEG plug-in attempts to do that. But looking at the console output (from GIMP 2.3), something seems to be not working correctly here: jpeg-load: found EXIF block (2969 bytes) jpeg-save: saving EXIF block (20 bytes) The "Save EXIF data" toggle in the JPEG dialog is insensitive. This might be a completely different problem that exists only in the HEAD branch. But we should definitely try to get this fixed for 2.4.
The following condition ni plug-ins/jpeg/jpeg-exif.c is causing the EXIF reader to return early without the EXIF data: if (! exif_content_get_entry (exif_data->ifd[EXIF_IFD_EXIF], EXIF_TAG_EXIF_VERSION)) return; It looks like the supplied image in comment #1 is lacking a ExifVersion field. This field is mandatory according to the EXIF specification and hence the image is broken. We should handle such images gracefully.
What exactly do you have in mind for "gracefully"?
We should try to preserve the EXIF data. In other words, don't touch it.
Note that some images have broken EXIF data containing an invalid EXIF version number and other strange things that should probably be sanitized by GIMP if possible. For example, see bug #166248 and my comment (#4) describing the strange contents of that EXIF block.
The check shown in comment #4 was added because libexif returns an exif_data structure whether or not the image actually has any exif data, so the structure needs to be checked for validity. This seemed to me to be a simple and robust way of doing it, which could not fail if the image followed the exif specification, but maybe you can think of a better way. (This comment is in response to an email from Mukund.)
Fix implemented in changeset 22377: 2007-05-02 Mukund Sivaraman <muks@mukund.org> * plug-ins/jpeg/jpeg-exif.c: Check if any other IFDs exist before rejecting an image's EXIF info. Fixes bug #377917.
You forgot to bumb libexif version requirement. Your fix requires a newer libexif.
The following change fixes the build with libexif < 0.6.13. You should still update, because you might hit this bug again now. 2007-05-06 Sven Neumann <sven@gimp.org> * plug-ins/jpeg/jpeg-exif.c (jpeg_apply_exif_data_to_image): only check for EXIF_TAG_GPS_VERSION_ID if it's defined (see bug #377917). This tag was added in libexif 0.6.13.