GNOME Bugzilla – Bug 168231
want EXIF rotation information via gdk_pixbuf_new_from_file
Last modified: 2010-07-10 04:04:51 UTC
I load image data into my program by calling gdk_pixbuf_new_from_file(). When the file that is loaded happens to be a JPEG file from a camera, I might need to rotate the image in order to display it properly, depending on what the EXIF data says. Currently, I think the only way to accomplish that is to parse the file twice: once in a format-agnostic way (via gdk_pixbuf_new_from_file) and then again in a JPEG-specific way (using libjpeg or something.) I would like either: 1) A way to tell gdk_pixbuf_new_from_file() to auto-rotate images before giving them to me; or 2) A way to interrogate the GdkPixbuf object and ask it whether it requires rotation (i.e., whether it started its life as a JPEG whose EXIF data said so.)
Would have to link the jpeg loader against libexif for this. I think we wontfixed a request+patch for that in the past, but we may reconsider. First step would probably be to dig out the old bug report and update the patch.
libexif.so is 78K. That doesn't seem like a hardship to me...
It is also adding new code paths to the image loaders which are the only security sensitive part of gtk...
Well, some minimal exif handling code could be put in the loader itself, instead of relying on libexif (which is fairly ugly code, and trivial to crash with all but the most recent versions).
*** Bug 158538 has been marked as a duplicate of this bug. ***
The JPEG loader doesn't seem to call gdk_pixbuf_set_option with the EXIF data, which would allow the client applications to use simple flip/rotation operations according to http://jpegclub.org/exif_orientation.html.
http://fresh.t-systems-sfr.com/linux/src/jpeginfo-1.6.0.tar.gz:a/jpeginfo-1.6.0/jpeginfo.c has some interesting sample code. I wonder whether it is a good idea to evaluate jpeglib's marker_list for all attributes. I fear that auto-collecting all metadata will lead to huge mallocs. Maybe we have to introduce new helpers to determine whether a pixbuf loader should load metadata, and maybe define a filter function?
We're taking a look at this at: http://bugzilla.gnome.org/show_bug.cgi?id=428725#c17 Please take a look... - Mike
Matthias, A patch is available at http://bugzilla.gnome.org/show_bug.cgi?id=428725#c43. Could you/someone review the patch to see if we're on the right track? - Mike
*** This bug has been marked as a duplicate of 428725 ***