Commit eab19066 authored by Raphael Quinet's avatar Raphael Quinet Committed by Raphaël Quinet
Browse files

Instead of passing any file to libexif blindly, check first that some JPEG

2007-06-12  Raphael Quinet  <raphael@gimp.org>

	* plug-ins/jpeg/jpeg-load.c (load_image): Instead of passing any
	file to libexif blindly, check first that some JPEG APP1 marker
	contains the EXIF header.

	* plug-ins/jpeg/jpeg-exif.c (jpeg_apply_exif_data_to_image):
	removed the tests that were checking for the presense of some EXIF
	tags such as the EXIF version before deciding if the data should
	be processed or not (bug #446809).

svn path=/trunk/; revision=22766
parent 5ead9fda
2007-06-12 Raphaël Quinet <raphael@gimp.org>
* plug-ins/jpeg/jpeg-load.c (load_image): Instead of passing any
file to libexif blindly, check first that some JPEG APP1 marker
contains the EXIF header.
* plug-ins/jpeg/jpeg-exif.c (jpeg_apply_exif_data_to_image):
removed the tests that were checking for the presense of some EXIF
tags such as the EXIF version before deciding if the data should
be processed or not (bug #446809).
2007-06-12 Sven Neumann <sven@gimp.org>
 
* plug-ins/common/curve_bend.c: initialize the GtkAdjustment used
......@@ -99,22 +99,14 @@ jpeg_apply_exif_data_to_image (const gchar *filename,
if (!exif_data->data || exif_data->size == 0)
return;
/*
* Unfortunately libexif may return a non-null exif_data even if the file
* contains no exif data. We check for validity by making sure it
* has suitable tags for the EXIF or GPS or Interoperability IFDs.
*
* EXIF_TAG_GPS_VERSION_ID was added in libexif 0.6.13.
/* Previous versions of this code were checking for the presence of
* some well-known tags in the EXIF data before proceeding because
* libexif could return a non-null exif_data even if the file
* contained no EXIF data. Now that the calling code in jpeg-load.c
* checks for a JPEG APP1 marker containing the EXIF header before
* calling this function, these tests are not necessary anymore.
* See also bug #446809.
*/
if ((! exif_content_get_entry (exif_data->ifd[EXIF_IFD_EXIF],
EXIF_TAG_EXIF_VERSION)) &&
#ifdef EXIF_TAG_GPS_VERSION_ID
(! exif_content_get_entry (exif_data->ifd[EXIF_IFD_GPS],
EXIF_TAG_GPS_VERSION_ID)) &&
#endif
(! exif_content_get_entry (exif_data->ifd[EXIF_IFD_INTEROPERABILITY],
EXIF_TAG_INTEROPERABILITY_VERSION)))
return;
gimp_metadata_store_exif (image_ID, exif_data);
......
......@@ -75,6 +75,7 @@ load_image (const gchar *filename,
GString *local_image_comments = NULL;
GimpParasite * volatile comment_parasite = NULL;
jpeg_saved_marker_ptr marker;
gboolean found_exif = FALSE;
/* We set up the normal JPEG error routines. */
cinfo.err = jpeg_std_error (&jerr.pub);
......@@ -83,6 +84,12 @@ load_image (const gchar *filename,
/* flag warnings, so we try to ignore corrupt EXIF data */
if (!preview)
{
/* Note: this usage of client_data and my_emit_message() may be a bit
redundant now that we only look for EXIF data in APP1 markers
instead of feeding the whole file to libexif immediately. We also
depend on a slighly more robust version of libexif. We should
consider removing this code in the future. --Raphael, 2007-06-12
*/
cinfo.client_data = GINT_TO_POINTER (FALSE);
jerr.pub.emit_message = my_emit_message;
......@@ -282,6 +289,8 @@ load_image (const gchar *filename,
/* FIXME: handle EXIF here once we don't use libexif anymore */
g_print ("jpeg-load: found EXIF block (%d bytes)\n",
(gint) (len - sizeof (JPEG_APP_HEADER_EXIF)));
/* FIXME: this flag is a workaround until we handle exif here */
found_exif = TRUE;
/* Note: maybe split the loop to ensure that the EXIF block is */
/* always parsed before any XMP packet */
}
......@@ -476,7 +485,7 @@ load_image (const gchar *filename,
#ifdef HAVE_EXIF
if (! GPOINTER_TO_INT (cinfo.client_data))
if (found_exif && ! GPOINTER_TO_INT (cinfo.client_data))
jpeg_apply_exif_data_to_image (filename, image_ID);
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment