Don't try to load EXIF data if any warnings happened, cause that likely

2004-07-07  Manish Singh  <yosh@gimp.org>

        * plug-ins/common/jpeg.c: Don't try to load EXIF data if any warnings
        happened, cause that likely means corruption and libexif doesn't
        handle that very happily. Addresses bug #145212. Perhaps the error and
        warning messages should be propagated to the user in the GUI somehow,
        currently they are not.
This commit is contained in:
Manish Singh 2004-07-07 12:33:58 +00:00 committed by manish
parent c5640071f5
commit 59736893ab
8 changed files with 386 additions and 231 deletions

View File

@ -1,3 +1,11 @@
2004-07-07 Manish Singh <yosh@gimp.org>
* plug-ins/common/jpeg.c: Don't try to load EXIF data if any warnings
happened, cause that likely means corruption and libexif doesn't
handle that very happily. Addresses bug #145212. Perhaps the error and
warning messages should be propagated to the user in the GUI somehow,
currently they are not.
2004-07-07 Michael Natterer <mitch@gimp.org>
* app/actions/edit-actions.c (edit_actions): added "..." to "Clear

View File

@ -177,14 +177,14 @@
/* See bugs #63610 and #61088 for a discussion about the quality settings */
#define DEFAULT_QUALITY 85
#define DEFAULT_SMOOTHING 0.0
#define DEFAULT_OPTIMIZE 1
#define DEFAULT_PROGRESSIVE 0
#define DEFAULT_BASELINE 1
#define DEFAULT_OPTIMIZE TRUE
#define DEFAULT_PROGRESSIVE FALSE
#define DEFAULT_BASELINE TRUE
#define DEFAULT_SUBSMP 0
#define DEFAULT_RESTART 0
#define DEFAULT_DCT 0
#define DEFAULT_PREVIEW 0
#define DEFAULT_EXIF 1
#define DEFAULT_PREVIEW FALSE
#define DEFAULT_EXIF TRUE
/* sg - these should not be global... */
static gint32 volatile image_ID_global = -1;
@ -197,16 +197,16 @@ static gboolean undo_touched = FALSE;
typedef struct
{
gdouble quality;
gdouble smoothing;
gint optimize;
gint progressive;
gint baseline;
gint subsmp;
gint restart;
gint dct;
gint preview;
gint save_exif;
gdouble quality;
gdouble smoothing;
gboolean optimize;
gboolean progressive;
gboolean baseline;
gint subsmp;
gint restart;
gint dct;
gboolean preview;
gboolean save_exif;
} JpegSaveVals;
typedef struct
@ -736,6 +736,14 @@ my_error_exit (j_common_ptr cinfo)
longjmp (myerr->setjmp_buffer, 1);
}
static void
my_emit_message (j_common_ptr cinfo,
int msg_level)
{
if (msg_level == -1)
cinfo->client_data = GINT_TO_POINTER(TRUE);
}
static gint32
load_image (const gchar *filename,
GimpRunMode runmode,
@ -768,6 +776,13 @@ load_image (const gchar *filename,
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* flag warnings, so we try to ignore corrupt EXIF data */
if (!preview)
{
cinfo.client_data = GINT_TO_POINTER(FALSE);
jerr.pub.emit_message = my_emit_message;
}
if ((infile = fopen (filename, "rb")) == NULL)
{
g_message (_("Could not open '%s' for reading: %s"),
@ -800,6 +815,7 @@ load_image (const gchar *filename,
destroy_preview();
gimp_quit ();
}
/* Now we can initialize the JPEG decompression object. */
jpeg_create_decompress (&cinfo);
@ -814,6 +830,7 @@ load_image (const gchar *filename,
/* Step 3: read file parameters with jpeg_read_header() */
(void) jpeg_read_header (&cinfo, TRUE);
/* We can ignore the return value from jpeg_read_header since
* (a) suspension is not possible with the stdio data source, and
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
@ -1111,26 +1128,30 @@ load_image (const gchar *filename,
#ifdef HAVE_EXIF
#define EXIF_HEADER_SIZE 8
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
if (! GPOINTER_TO_INT (cinfo.client_data))
{
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
#endif
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
}
else
g_message (_("JPEG loaded with warnings, EXIF data ignored"));
#endif
}
return image_ID;

View File

@ -177,14 +177,14 @@
/* See bugs #63610 and #61088 for a discussion about the quality settings */
#define DEFAULT_QUALITY 85
#define DEFAULT_SMOOTHING 0.0
#define DEFAULT_OPTIMIZE 1
#define DEFAULT_PROGRESSIVE 0
#define DEFAULT_BASELINE 1
#define DEFAULT_OPTIMIZE TRUE
#define DEFAULT_PROGRESSIVE FALSE
#define DEFAULT_BASELINE TRUE
#define DEFAULT_SUBSMP 0
#define DEFAULT_RESTART 0
#define DEFAULT_DCT 0
#define DEFAULT_PREVIEW 0
#define DEFAULT_EXIF 1
#define DEFAULT_PREVIEW FALSE
#define DEFAULT_EXIF TRUE
/* sg - these should not be global... */
static gint32 volatile image_ID_global = -1;
@ -197,16 +197,16 @@ static gboolean undo_touched = FALSE;
typedef struct
{
gdouble quality;
gdouble smoothing;
gint optimize;
gint progressive;
gint baseline;
gint subsmp;
gint restart;
gint dct;
gint preview;
gint save_exif;
gdouble quality;
gdouble smoothing;
gboolean optimize;
gboolean progressive;
gboolean baseline;
gint subsmp;
gint restart;
gint dct;
gboolean preview;
gboolean save_exif;
} JpegSaveVals;
typedef struct
@ -736,6 +736,14 @@ my_error_exit (j_common_ptr cinfo)
longjmp (myerr->setjmp_buffer, 1);
}
static void
my_emit_message (j_common_ptr cinfo,
int msg_level)
{
if (msg_level == -1)
cinfo->client_data = GINT_TO_POINTER(TRUE);
}
static gint32
load_image (const gchar *filename,
GimpRunMode runmode,
@ -768,6 +776,13 @@ load_image (const gchar *filename,
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* flag warnings, so we try to ignore corrupt EXIF data */
if (!preview)
{
cinfo.client_data = GINT_TO_POINTER(FALSE);
jerr.pub.emit_message = my_emit_message;
}
if ((infile = fopen (filename, "rb")) == NULL)
{
g_message (_("Could not open '%s' for reading: %s"),
@ -800,6 +815,7 @@ load_image (const gchar *filename,
destroy_preview();
gimp_quit ();
}
/* Now we can initialize the JPEG decompression object. */
jpeg_create_decompress (&cinfo);
@ -814,6 +830,7 @@ load_image (const gchar *filename,
/* Step 3: read file parameters with jpeg_read_header() */
(void) jpeg_read_header (&cinfo, TRUE);
/* We can ignore the return value from jpeg_read_header since
* (a) suspension is not possible with the stdio data source, and
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
@ -1111,26 +1128,30 @@ load_image (const gchar *filename,
#ifdef HAVE_EXIF
#define EXIF_HEADER_SIZE 8
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
if (! GPOINTER_TO_INT (cinfo.client_data))
{
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
#endif
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
}
else
g_message (_("JPEG loaded with warnings, EXIF data ignored"));
#endif
}
return image_ID;

View File

@ -177,14 +177,14 @@
/* See bugs #63610 and #61088 for a discussion about the quality settings */
#define DEFAULT_QUALITY 85
#define DEFAULT_SMOOTHING 0.0
#define DEFAULT_OPTIMIZE 1
#define DEFAULT_PROGRESSIVE 0
#define DEFAULT_BASELINE 1
#define DEFAULT_OPTIMIZE TRUE
#define DEFAULT_PROGRESSIVE FALSE
#define DEFAULT_BASELINE TRUE
#define DEFAULT_SUBSMP 0
#define DEFAULT_RESTART 0
#define DEFAULT_DCT 0
#define DEFAULT_PREVIEW 0
#define DEFAULT_EXIF 1
#define DEFAULT_PREVIEW FALSE
#define DEFAULT_EXIF TRUE
/* sg - these should not be global... */
static gint32 volatile image_ID_global = -1;
@ -197,16 +197,16 @@ static gboolean undo_touched = FALSE;
typedef struct
{
gdouble quality;
gdouble smoothing;
gint optimize;
gint progressive;
gint baseline;
gint subsmp;
gint restart;
gint dct;
gint preview;
gint save_exif;
gdouble quality;
gdouble smoothing;
gboolean optimize;
gboolean progressive;
gboolean baseline;
gint subsmp;
gint restart;
gint dct;
gboolean preview;
gboolean save_exif;
} JpegSaveVals;
typedef struct
@ -736,6 +736,14 @@ my_error_exit (j_common_ptr cinfo)
longjmp (myerr->setjmp_buffer, 1);
}
static void
my_emit_message (j_common_ptr cinfo,
int msg_level)
{
if (msg_level == -1)
cinfo->client_data = GINT_TO_POINTER(TRUE);
}
static gint32
load_image (const gchar *filename,
GimpRunMode runmode,
@ -768,6 +776,13 @@ load_image (const gchar *filename,
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* flag warnings, so we try to ignore corrupt EXIF data */
if (!preview)
{
cinfo.client_data = GINT_TO_POINTER(FALSE);
jerr.pub.emit_message = my_emit_message;
}
if ((infile = fopen (filename, "rb")) == NULL)
{
g_message (_("Could not open '%s' for reading: %s"),
@ -800,6 +815,7 @@ load_image (const gchar *filename,
destroy_preview();
gimp_quit ();
}
/* Now we can initialize the JPEG decompression object. */
jpeg_create_decompress (&cinfo);
@ -814,6 +830,7 @@ load_image (const gchar *filename,
/* Step 3: read file parameters with jpeg_read_header() */
(void) jpeg_read_header (&cinfo, TRUE);
/* We can ignore the return value from jpeg_read_header since
* (a) suspension is not possible with the stdio data source, and
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
@ -1111,26 +1128,30 @@ load_image (const gchar *filename,
#ifdef HAVE_EXIF
#define EXIF_HEADER_SIZE 8
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
if (! GPOINTER_TO_INT (cinfo.client_data))
{
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
#endif
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
}
else
g_message (_("JPEG loaded with warnings, EXIF data ignored"));
#endif
}
return image_ID;

View File

@ -177,14 +177,14 @@
/* See bugs #63610 and #61088 for a discussion about the quality settings */
#define DEFAULT_QUALITY 85
#define DEFAULT_SMOOTHING 0.0
#define DEFAULT_OPTIMIZE 1
#define DEFAULT_PROGRESSIVE 0
#define DEFAULT_BASELINE 1
#define DEFAULT_OPTIMIZE TRUE
#define DEFAULT_PROGRESSIVE FALSE
#define DEFAULT_BASELINE TRUE
#define DEFAULT_SUBSMP 0
#define DEFAULT_RESTART 0
#define DEFAULT_DCT 0
#define DEFAULT_PREVIEW 0
#define DEFAULT_EXIF 1
#define DEFAULT_PREVIEW FALSE
#define DEFAULT_EXIF TRUE
/* sg - these should not be global... */
static gint32 volatile image_ID_global = -1;
@ -197,16 +197,16 @@ static gboolean undo_touched = FALSE;
typedef struct
{
gdouble quality;
gdouble smoothing;
gint optimize;
gint progressive;
gint baseline;
gint subsmp;
gint restart;
gint dct;
gint preview;
gint save_exif;
gdouble quality;
gdouble smoothing;
gboolean optimize;
gboolean progressive;
gboolean baseline;
gint subsmp;
gint restart;
gint dct;
gboolean preview;
gboolean save_exif;
} JpegSaveVals;
typedef struct
@ -736,6 +736,14 @@ my_error_exit (j_common_ptr cinfo)
longjmp (myerr->setjmp_buffer, 1);
}
static void
my_emit_message (j_common_ptr cinfo,
int msg_level)
{
if (msg_level == -1)
cinfo->client_data = GINT_TO_POINTER(TRUE);
}
static gint32
load_image (const gchar *filename,
GimpRunMode runmode,
@ -768,6 +776,13 @@ load_image (const gchar *filename,
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* flag warnings, so we try to ignore corrupt EXIF data */
if (!preview)
{
cinfo.client_data = GINT_TO_POINTER(FALSE);
jerr.pub.emit_message = my_emit_message;
}
if ((infile = fopen (filename, "rb")) == NULL)
{
g_message (_("Could not open '%s' for reading: %s"),
@ -800,6 +815,7 @@ load_image (const gchar *filename,
destroy_preview();
gimp_quit ();
}
/* Now we can initialize the JPEG decompression object. */
jpeg_create_decompress (&cinfo);
@ -814,6 +830,7 @@ load_image (const gchar *filename,
/* Step 3: read file parameters with jpeg_read_header() */
(void) jpeg_read_header (&cinfo, TRUE);
/* We can ignore the return value from jpeg_read_header since
* (a) suspension is not possible with the stdio data source, and
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
@ -1111,26 +1128,30 @@ load_image (const gchar *filename,
#ifdef HAVE_EXIF
#define EXIF_HEADER_SIZE 8
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
if (! GPOINTER_TO_INT (cinfo.client_data))
{
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
#endif
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
}
else
g_message (_("JPEG loaded with warnings, EXIF data ignored"));
#endif
}
return image_ID;

View File

@ -177,14 +177,14 @@
/* See bugs #63610 and #61088 for a discussion about the quality settings */
#define DEFAULT_QUALITY 85
#define DEFAULT_SMOOTHING 0.0
#define DEFAULT_OPTIMIZE 1
#define DEFAULT_PROGRESSIVE 0
#define DEFAULT_BASELINE 1
#define DEFAULT_OPTIMIZE TRUE
#define DEFAULT_PROGRESSIVE FALSE
#define DEFAULT_BASELINE TRUE
#define DEFAULT_SUBSMP 0
#define DEFAULT_RESTART 0
#define DEFAULT_DCT 0
#define DEFAULT_PREVIEW 0
#define DEFAULT_EXIF 1
#define DEFAULT_PREVIEW FALSE
#define DEFAULT_EXIF TRUE
/* sg - these should not be global... */
static gint32 volatile image_ID_global = -1;
@ -197,16 +197,16 @@ static gboolean undo_touched = FALSE;
typedef struct
{
gdouble quality;
gdouble smoothing;
gint optimize;
gint progressive;
gint baseline;
gint subsmp;
gint restart;
gint dct;
gint preview;
gint save_exif;
gdouble quality;
gdouble smoothing;
gboolean optimize;
gboolean progressive;
gboolean baseline;
gint subsmp;
gint restart;
gint dct;
gboolean preview;
gboolean save_exif;
} JpegSaveVals;
typedef struct
@ -736,6 +736,14 @@ my_error_exit (j_common_ptr cinfo)
longjmp (myerr->setjmp_buffer, 1);
}
static void
my_emit_message (j_common_ptr cinfo,
int msg_level)
{
if (msg_level == -1)
cinfo->client_data = GINT_TO_POINTER(TRUE);
}
static gint32
load_image (const gchar *filename,
GimpRunMode runmode,
@ -768,6 +776,13 @@ load_image (const gchar *filename,
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* flag warnings, so we try to ignore corrupt EXIF data */
if (!preview)
{
cinfo.client_data = GINT_TO_POINTER(FALSE);
jerr.pub.emit_message = my_emit_message;
}
if ((infile = fopen (filename, "rb")) == NULL)
{
g_message (_("Could not open '%s' for reading: %s"),
@ -800,6 +815,7 @@ load_image (const gchar *filename,
destroy_preview();
gimp_quit ();
}
/* Now we can initialize the JPEG decompression object. */
jpeg_create_decompress (&cinfo);
@ -814,6 +830,7 @@ load_image (const gchar *filename,
/* Step 3: read file parameters with jpeg_read_header() */
(void) jpeg_read_header (&cinfo, TRUE);
/* We can ignore the return value from jpeg_read_header since
* (a) suspension is not possible with the stdio data source, and
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
@ -1111,26 +1128,30 @@ load_image (const gchar *filename,
#ifdef HAVE_EXIF
#define EXIF_HEADER_SIZE 8
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
if (! GPOINTER_TO_INT (cinfo.client_data))
{
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
#endif
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
}
else
g_message (_("JPEG loaded with warnings, EXIF data ignored"));
#endif
}
return image_ID;

View File

@ -177,14 +177,14 @@
/* See bugs #63610 and #61088 for a discussion about the quality settings */
#define DEFAULT_QUALITY 85
#define DEFAULT_SMOOTHING 0.0
#define DEFAULT_OPTIMIZE 1
#define DEFAULT_PROGRESSIVE 0
#define DEFAULT_BASELINE 1
#define DEFAULT_OPTIMIZE TRUE
#define DEFAULT_PROGRESSIVE FALSE
#define DEFAULT_BASELINE TRUE
#define DEFAULT_SUBSMP 0
#define DEFAULT_RESTART 0
#define DEFAULT_DCT 0
#define DEFAULT_PREVIEW 0
#define DEFAULT_EXIF 1
#define DEFAULT_PREVIEW FALSE
#define DEFAULT_EXIF TRUE
/* sg - these should not be global... */
static gint32 volatile image_ID_global = -1;
@ -197,16 +197,16 @@ static gboolean undo_touched = FALSE;
typedef struct
{
gdouble quality;
gdouble smoothing;
gint optimize;
gint progressive;
gint baseline;
gint subsmp;
gint restart;
gint dct;
gint preview;
gint save_exif;
gdouble quality;
gdouble smoothing;
gboolean optimize;
gboolean progressive;
gboolean baseline;
gint subsmp;
gint restart;
gint dct;
gboolean preview;
gboolean save_exif;
} JpegSaveVals;
typedef struct
@ -736,6 +736,14 @@ my_error_exit (j_common_ptr cinfo)
longjmp (myerr->setjmp_buffer, 1);
}
static void
my_emit_message (j_common_ptr cinfo,
int msg_level)
{
if (msg_level == -1)
cinfo->client_data = GINT_TO_POINTER(TRUE);
}
static gint32
load_image (const gchar *filename,
GimpRunMode runmode,
@ -768,6 +776,13 @@ load_image (const gchar *filename,
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* flag warnings, so we try to ignore corrupt EXIF data */
if (!preview)
{
cinfo.client_data = GINT_TO_POINTER(FALSE);
jerr.pub.emit_message = my_emit_message;
}
if ((infile = fopen (filename, "rb")) == NULL)
{
g_message (_("Could not open '%s' for reading: %s"),
@ -800,6 +815,7 @@ load_image (const gchar *filename,
destroy_preview();
gimp_quit ();
}
/* Now we can initialize the JPEG decompression object. */
jpeg_create_decompress (&cinfo);
@ -814,6 +830,7 @@ load_image (const gchar *filename,
/* Step 3: read file parameters with jpeg_read_header() */
(void) jpeg_read_header (&cinfo, TRUE);
/* We can ignore the return value from jpeg_read_header since
* (a) suspension is not possible with the stdio data source, and
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
@ -1111,26 +1128,30 @@ load_image (const gchar *filename,
#ifdef HAVE_EXIF
#define EXIF_HEADER_SIZE 8
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
if (! GPOINTER_TO_INT (cinfo.client_data))
{
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
#endif
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
}
else
g_message (_("JPEG loaded with warnings, EXIF data ignored"));
#endif
}
return image_ID;

View File

@ -177,14 +177,14 @@
/* See bugs #63610 and #61088 for a discussion about the quality settings */
#define DEFAULT_QUALITY 85
#define DEFAULT_SMOOTHING 0.0
#define DEFAULT_OPTIMIZE 1
#define DEFAULT_PROGRESSIVE 0
#define DEFAULT_BASELINE 1
#define DEFAULT_OPTIMIZE TRUE
#define DEFAULT_PROGRESSIVE FALSE
#define DEFAULT_BASELINE TRUE
#define DEFAULT_SUBSMP 0
#define DEFAULT_RESTART 0
#define DEFAULT_DCT 0
#define DEFAULT_PREVIEW 0
#define DEFAULT_EXIF 1
#define DEFAULT_PREVIEW FALSE
#define DEFAULT_EXIF TRUE
/* sg - these should not be global... */
static gint32 volatile image_ID_global = -1;
@ -197,16 +197,16 @@ static gboolean undo_touched = FALSE;
typedef struct
{
gdouble quality;
gdouble smoothing;
gint optimize;
gint progressive;
gint baseline;
gint subsmp;
gint restart;
gint dct;
gint preview;
gint save_exif;
gdouble quality;
gdouble smoothing;
gboolean optimize;
gboolean progressive;
gboolean baseline;
gint subsmp;
gint restart;
gint dct;
gboolean preview;
gboolean save_exif;
} JpegSaveVals;
typedef struct
@ -736,6 +736,14 @@ my_error_exit (j_common_ptr cinfo)
longjmp (myerr->setjmp_buffer, 1);
}
static void
my_emit_message (j_common_ptr cinfo,
int msg_level)
{
if (msg_level == -1)
cinfo->client_data = GINT_TO_POINTER(TRUE);
}
static gint32
load_image (const gchar *filename,
GimpRunMode runmode,
@ -768,6 +776,13 @@ load_image (const gchar *filename,
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
/* flag warnings, so we try to ignore corrupt EXIF data */
if (!preview)
{
cinfo.client_data = GINT_TO_POINTER(FALSE);
jerr.pub.emit_message = my_emit_message;
}
if ((infile = fopen (filename, "rb")) == NULL)
{
g_message (_("Could not open '%s' for reading: %s"),
@ -800,6 +815,7 @@ load_image (const gchar *filename,
destroy_preview();
gimp_quit ();
}
/* Now we can initialize the JPEG decompression object. */
jpeg_create_decompress (&cinfo);
@ -814,6 +830,7 @@ load_image (const gchar *filename,
/* Step 3: read file parameters with jpeg_read_header() */
(void) jpeg_read_header (&cinfo, TRUE);
/* We can ignore the return value from jpeg_read_header since
* (a) suspension is not possible with the stdio data source, and
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
@ -1111,26 +1128,30 @@ load_image (const gchar *filename,
#ifdef HAVE_EXIF
#define EXIF_HEADER_SIZE 8
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
if (! GPOINTER_TO_INT (cinfo.client_data))
{
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
#endif
guchar *exif_buf;
guint exif_buf_len;
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
if (exif_buf_len > EXIF_HEADER_SIZE)
{
exif_parasite = gimp_parasite_new ("exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
free (exif_buf);
}
}
else
g_message (_("JPEG loaded with warnings, EXIF data ignored"));
#endif
}
return image_ID;