Commit 1abfa8da authored by Dave Neary's avatar Dave Neary Committed by David Neary
Browse files

configure.in plug-ins/common/Makefile.am Add support for the keeping of



2003-06-22  Dave Neary  <bolsh@gimp.org>

	* configure.in
	* plug-ins/common/Makefile.am
	* plug-ins/common/jpeg.c: Add support for the keeping of EXIF
	information in jpeg files. This is step 1 in the overall plan to
	an all-singing, all-dancing metadata editor. Next step is to do
	the same thing for TIFFs, then to do both properly as a number of
	parasites rather than one big one, and then to allow a generic
	metadata editor, as well as (possibly) adding a nice way to
	manipulate exif data in the jpeg plug-in while saving.

	This is a modified patch of one posted to the devel list by Lutz
	Muller in February 2002, and subsequently added to bug #56443.
	Sorry it took so long Lutz.
parent f4c1777a
2003-06-22 Dave Neary <bolsh@gimp.org>
* configure.in
* plug-ins/common/Makefile.am
* plug-ins/common/jpeg.c: Add support for the keeping of EXIF
information in jpeg files. This is step 1 in the overall plan to
an all-singing, all-dancing metadata editor. Next step is to do
the same thing for TIFFs, then to do both properly as a number of
parasites rather than one big one, and then to allow a generic
metadata editor, as well as (possibly) adding a nice way to
manipulate exif data in the jpeg plug-in while saving.
This is a modified patch of one posted to the devel list by Lutz
Muller in February 2002, and subsequently added to bug #56443.
Sorry it took so long Lutz.
2003-06-22 Dave Neary <bolsh@gimp.org>
 
* app/config/gimpbaseconfig.c: Increased default tile
......@@ -909,6 +909,37 @@ if test "x$enable_python" != xno; then
fi
AM_CONDITIONAL(BUILD_PYTHON, test "x$enable_python" != xno)
############################################################
# libexif: Library to allow exif tags to be read from, and
# saved to, jpeg files. Currently, this permits exif data to
# avoid destruction, but no data modification is performed.
############################################################
exif_msg="no - EXIF support will not be built into the JPEG plug-in.
libexif is available from http://www.sourceforge.net/projects/libexif"
AC_ARG_WITH(libexif, [ --without-libexif build without EXIF support])
if test x$with_libexif != xno && test -z "$LIBEXIF"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config)
if test -n "${PKG_CONFIG}"; then
AC_MSG_CHECKING([for libexif])
if ${PKG_CONFIG} --exists libexif > /dev/null 2>&1; then
EXIF_CFLAGS=`$PKG_CONFIG --cflags libexif`
EXIF_LIBS=`$PKG_CONFIG --libs libexif`
exif_msg="yes"
AC_DEFINE(HAVE_EXIF, 1, \
"Defined if EXIF support is to be added to the JPEG plug-in")
fi
AC_MSG_RESULT($exif_msg)
fi
fi
AC_SUBST(EXIF_CFLAGS)
AC_SUBST(EXIF_LIBS)
###########################################################
# Some plug-ins don't build on Win32, others are Win32-only
......
......@@ -908,6 +908,8 @@ jigsaw_LDADD = \
jpeg_SOURCES = \
jpeg.c
jpeg_CFLAGS = $(EXIF_CFLAGS)
jpeg_LDADD = \
$(top_builddir)/libgimp/libgimpui-$(LT_RELEASE).la \
$(top_builddir)/libgimpwidgets/libgimpwidgets-$(LT_RELEASE).la \
......@@ -916,7 +918,8 @@ jpeg_LDADD = \
$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la \
$(LIBJPEG) \
$(GTK_LIBS) \
$(INTLLIBS)
$(INTLLIBS) \
$(EXIF_LIBS)
laplace_SOURCES = \
laplace.c
......
......@@ -128,6 +128,17 @@
* a GtkTextView/GtkTextBuffer couple;
*/
/*
* 22-JUN-03 - add support for keeping EXIF information
* - Dave Neary <bolsh@gimp.org>
*
* This is little more than a modified version fo a patch from the
* libexif owner (Lutz Muller) which attaches exif information to
* a GimpImage, and if there is infoprmation available at save
* time, writes it out. No modification of the exif data is
* currently possible.
*/
#include "config.h" /* configure cares about HAVE_PROGRESSIVE_JPEG */
#include <glib.h> /* We want glib.h first because of some
......@@ -147,6 +158,10 @@
#include <jpeglib.h>
#include <jerror.h>
#ifdef HAVE_EXIF
#include <libexif/exif-data.h>
#endif /* HAVE_EXIF */
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
......@@ -281,6 +296,9 @@ static gchar *image_comment = NULL;
static GtkWidget *restart_markers_scale = NULL;
static GtkWidget *restart_markers_label = NULL;
#ifdef HAVE_EXIF
static ExifData *exif_data = NULL;
#endif /* HAVE_EXIF */
MAIN ()
......@@ -425,6 +443,11 @@ run (gchar *name,
break;
}
#ifdef HAVE_EXIF
exif_data_unref (exif_data);
exif_data = NULL;
#endif /* HAVE_EXIF */
g_free (image_comment);
image_comment = NULL;
......@@ -435,6 +458,15 @@ run (gchar *name,
gimp_parasite_free (parasite);
}
#ifdef HAVE_EXIF
parasite = gimp_image_parasite_find (orig_image_ID, "jpeg-exif-data");
if (parasite)
{
exif_data = exif_data_new_from_data (parasite->data, parasite->size);
gimp_parasite_free (parasite);
}
#endif /* HAVE_EXIF */
jsvals.quality = DEFAULT_QUALITY;
jsvals.smoothing = DEFAULT_SMOOTHING;
jsvals.optimize = DEFAULT_OPTIMIZE;
......@@ -724,6 +756,13 @@ load_image (gchar *filename,
GimpParasite * volatile comment_parasite = NULL;
#ifdef HAVE_EXIF
GimpParasite *exif_parasite = NULL;
ExifData *exif_data = NULL;
guchar *exif_buf = NULL;
guint exif_buf_len = 0;
#endif
/* We set up the normal JPEG error routines. */
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
......@@ -1060,6 +1099,22 @@ load_image (gchar *filename,
comment_parasite = NULL;
}
#ifdef HAVE_EXIF
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
exif_parasite = gimp_parasite_new ("jpeg-exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
g_free (exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
#endif
}
return image_ID;
......@@ -1190,6 +1245,11 @@ save_image (gchar *filename,
gint rowstride, yend;
gint i, j;
#ifdef HAVE_EXIF
guchar *exif_buf;
guint exif_buf_len;
#endif
drawable = gimp_drawable_get (drawable_ID);
drawable_type = gimp_drawable_type (drawable_ID);
gimp_pixel_rgn_init (&pixel_rgn, drawable,
......@@ -1393,6 +1453,15 @@ save_image (gchar *filename,
*/
jpeg_start_compress (&cinfo, TRUE);
#ifdef HAVE_EXIF
if (exif_data)
{
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
jpeg_write_marker (&cinfo, 0xe1, exif_buf, exif_buf_len);
g_free (exif_buf);
}
#endif
/* Step 4.1: Write the comment out - pw */
if (image_comment && *image_comment)
{
......
......@@ -128,6 +128,17 @@
* a GtkTextView/GtkTextBuffer couple;
*/
/*
* 22-JUN-03 - add support for keeping EXIF information
* - Dave Neary <bolsh@gimp.org>
*
* This is little more than a modified version fo a patch from the
* libexif owner (Lutz Muller) which attaches exif information to
* a GimpImage, and if there is infoprmation available at save
* time, writes it out. No modification of the exif data is
* currently possible.
*/
#include "config.h" /* configure cares about HAVE_PROGRESSIVE_JPEG */
#include <glib.h> /* We want glib.h first because of some
......@@ -147,6 +158,10 @@
#include <jpeglib.h>
#include <jerror.h>
#ifdef HAVE_EXIF
#include <libexif/exif-data.h>
#endif /* HAVE_EXIF */
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
......@@ -281,6 +296,9 @@ static gchar *image_comment = NULL;
static GtkWidget *restart_markers_scale = NULL;
static GtkWidget *restart_markers_label = NULL;
#ifdef HAVE_EXIF
static ExifData *exif_data = NULL;
#endif /* HAVE_EXIF */
MAIN ()
......@@ -425,6 +443,11 @@ run (gchar *name,
break;
}
#ifdef HAVE_EXIF
exif_data_unref (exif_data);
exif_data = NULL;
#endif /* HAVE_EXIF */
g_free (image_comment);
image_comment = NULL;
......@@ -435,6 +458,15 @@ run (gchar *name,
gimp_parasite_free (parasite);
}
#ifdef HAVE_EXIF
parasite = gimp_image_parasite_find (orig_image_ID, "jpeg-exif-data");
if (parasite)
{
exif_data = exif_data_new_from_data (parasite->data, parasite->size);
gimp_parasite_free (parasite);
}
#endif /* HAVE_EXIF */
jsvals.quality = DEFAULT_QUALITY;
jsvals.smoothing = DEFAULT_SMOOTHING;
jsvals.optimize = DEFAULT_OPTIMIZE;
......@@ -724,6 +756,13 @@ load_image (gchar *filename,
GimpParasite * volatile comment_parasite = NULL;
#ifdef HAVE_EXIF
GimpParasite *exif_parasite = NULL;
ExifData *exif_data = NULL;
guchar *exif_buf = NULL;
guint exif_buf_len = 0;
#endif
/* We set up the normal JPEG error routines. */
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
......@@ -1060,6 +1099,22 @@ load_image (gchar *filename,
comment_parasite = NULL;
}
#ifdef HAVE_EXIF
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
exif_parasite = gimp_parasite_new ("jpeg-exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
g_free (exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
#endif
}
return image_ID;
......@@ -1190,6 +1245,11 @@ save_image (gchar *filename,
gint rowstride, yend;
gint i, j;
#ifdef HAVE_EXIF
guchar *exif_buf;
guint exif_buf_len;
#endif
drawable = gimp_drawable_get (drawable_ID);
drawable_type = gimp_drawable_type (drawable_ID);
gimp_pixel_rgn_init (&pixel_rgn, drawable,
......@@ -1393,6 +1453,15 @@ save_image (gchar *filename,
*/
jpeg_start_compress (&cinfo, TRUE);
#ifdef HAVE_EXIF
if (exif_data)
{
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
jpeg_write_marker (&cinfo, 0xe1, exif_buf, exif_buf_len);
g_free (exif_buf);
}
#endif
/* Step 4.1: Write the comment out - pw */
if (image_comment && *image_comment)
{
......
......@@ -128,6 +128,17 @@
* a GtkTextView/GtkTextBuffer couple;
*/
/*
* 22-JUN-03 - add support for keeping EXIF information
* - Dave Neary <bolsh@gimp.org>
*
* This is little more than a modified version fo a patch from the
* libexif owner (Lutz Muller) which attaches exif information to
* a GimpImage, and if there is infoprmation available at save
* time, writes it out. No modification of the exif data is
* currently possible.
*/
#include "config.h" /* configure cares about HAVE_PROGRESSIVE_JPEG */
#include <glib.h> /* We want glib.h first because of some
......@@ -147,6 +158,10 @@
#include <jpeglib.h>
#include <jerror.h>
#ifdef HAVE_EXIF
#include <libexif/exif-data.h>
#endif /* HAVE_EXIF */
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
......@@ -281,6 +296,9 @@ static gchar *image_comment = NULL;
static GtkWidget *restart_markers_scale = NULL;
static GtkWidget *restart_markers_label = NULL;
#ifdef HAVE_EXIF
static ExifData *exif_data = NULL;
#endif /* HAVE_EXIF */
MAIN ()
......@@ -425,6 +443,11 @@ run (gchar *name,
break;
}
#ifdef HAVE_EXIF
exif_data_unref (exif_data);
exif_data = NULL;
#endif /* HAVE_EXIF */
g_free (image_comment);
image_comment = NULL;
......@@ -435,6 +458,15 @@ run (gchar *name,
gimp_parasite_free (parasite);
}
#ifdef HAVE_EXIF
parasite = gimp_image_parasite_find (orig_image_ID, "jpeg-exif-data");
if (parasite)
{
exif_data = exif_data_new_from_data (parasite->data, parasite->size);
gimp_parasite_free (parasite);
}
#endif /* HAVE_EXIF */
jsvals.quality = DEFAULT_QUALITY;
jsvals.smoothing = DEFAULT_SMOOTHING;
jsvals.optimize = DEFAULT_OPTIMIZE;
......@@ -724,6 +756,13 @@ load_image (gchar *filename,
GimpParasite * volatile comment_parasite = NULL;
#ifdef HAVE_EXIF
GimpParasite *exif_parasite = NULL;
ExifData *exif_data = NULL;
guchar *exif_buf = NULL;
guint exif_buf_len = 0;
#endif
/* We set up the normal JPEG error routines. */
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
......@@ -1060,6 +1099,22 @@ load_image (gchar *filename,
comment_parasite = NULL;
}
#ifdef HAVE_EXIF
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
exif_parasite = gimp_parasite_new ("jpeg-exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
g_free (exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
#endif
}
return image_ID;
......@@ -1190,6 +1245,11 @@ save_image (gchar *filename,
gint rowstride, yend;
gint i, j;
#ifdef HAVE_EXIF
guchar *exif_buf;
guint exif_buf_len;
#endif
drawable = gimp_drawable_get (drawable_ID);
drawable_type = gimp_drawable_type (drawable_ID);
gimp_pixel_rgn_init (&pixel_rgn, drawable,
......@@ -1393,6 +1453,15 @@ save_image (gchar *filename,
*/
jpeg_start_compress (&cinfo, TRUE);
#ifdef HAVE_EXIF
if (exif_data)
{
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
jpeg_write_marker (&cinfo, 0xe1, exif_buf, exif_buf_len);
g_free (exif_buf);
}
#endif
/* Step 4.1: Write the comment out - pw */
if (image_comment && *image_comment)
{
......
......@@ -128,6 +128,17 @@
* a GtkTextView/GtkTextBuffer couple;
*/
/*
* 22-JUN-03 - add support for keeping EXIF information
* - Dave Neary <bolsh@gimp.org>
*
* This is little more than a modified version fo a patch from the
* libexif owner (Lutz Muller) which attaches exif information to
* a GimpImage, and if there is infoprmation available at save
* time, writes it out. No modification of the exif data is
* currently possible.
*/
#include "config.h" /* configure cares about HAVE_PROGRESSIVE_JPEG */
#include <glib.h> /* We want glib.h first because of some
......@@ -147,6 +158,10 @@
#include <jpeglib.h>
#include <jerror.h>
#ifdef HAVE_EXIF
#include <libexif/exif-data.h>
#endif /* HAVE_EXIF */
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
......@@ -281,6 +296,9 @@ static gchar *image_comment = NULL;
static GtkWidget *restart_markers_scale = NULL;
static GtkWidget *restart_markers_label = NULL;
#ifdef HAVE_EXIF
static ExifData *exif_data = NULL;
#endif /* HAVE_EXIF */
MAIN ()
......@@ -425,6 +443,11 @@ run (gchar *name,
break;
}
#ifdef HAVE_EXIF
exif_data_unref (exif_data);
exif_data = NULL;
#endif /* HAVE_EXIF */
g_free (image_comment);
image_comment = NULL;
......@@ -435,6 +458,15 @@ run (gchar *name,
gimp_parasite_free (parasite);
}
#ifdef HAVE_EXIF
parasite = gimp_image_parasite_find (orig_image_ID, "jpeg-exif-data");
if (parasite)
{
exif_data = exif_data_new_from_data (parasite->data, parasite->size);
gimp_parasite_free (parasite);
}
#endif /* HAVE_EXIF */
jsvals.quality = DEFAULT_QUALITY;
jsvals.smoothing = DEFAULT_SMOOTHING;
jsvals.optimize = DEFAULT_OPTIMIZE;
......@@ -724,6 +756,13 @@ load_image (gchar *filename,
GimpParasite * volatile comment_parasite = NULL;
#ifdef HAVE_EXIF
GimpParasite *exif_parasite = NULL;
ExifData *exif_data = NULL;
guchar *exif_buf = NULL;
guint exif_buf_len = 0;
#endif
/* We set up the normal JPEG error routines. */
cinfo.err = jpeg_std_error (&jerr.pub);
jerr.pub.error_exit = my_error_exit;
......@@ -1060,6 +1099,22 @@ load_image (gchar *filename,
comment_parasite = NULL;
}
#ifdef HAVE_EXIF
exif_data = exif_data_new_from_file (filename);
if (exif_data)
{
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
exif_data_unref (exif_data);
exif_parasite = gimp_parasite_new ("jpeg-exif-data",
GIMP_PARASITE_PERSISTENT,
exif_buf_len, exif_buf);
g_free (exif_buf);
gimp_image_parasite_attach (image_ID, exif_parasite);
gimp_parasite_free (exif_parasite);
}
#endif
}
return image_ID;
......@@ -1190,6 +1245,11 @@ save_image (gchar *filename,
gint rowstride, yend;
gint i, j;
#ifdef HAVE_EXIF
guchar *exif_buf;
guint exif_buf_len;
#endif
drawable = gimp_drawable_get (drawable_ID);
drawable_type = gimp_drawable_type (drawable_ID);
gimp_pixel_rgn_init (&pixel_rgn, drawable,
......@@ -1393,6 +1453,15 @@ save_image (gchar *filename,
*/
jpeg_start_compress (&cinfo, TRUE);
#ifdef HAVE_EXIF
if (exif_data)
{
exif_data_save_data (exif_data, &exif_buf, &exif_buf_len);
jpeg_write_marker (&cinfo, 0xe1, exif_buf, exif_buf_len);
g_free (exif_buf);
}
#endif
/* Step 4.1: Write the comment out - pw */
if (image_comment && *image_comment)
{
......
......@@ -128,6 +128,17 @@
* a GtkTextView/GtkTextBuffer couple;
*/
/*
* 22-JUN-03 - add support for keeping EXIF information
* - Dave Neary <bolsh@gimp.org>
*
* This is little more than a modified version fo a patch from the
* libexif owner (Lutz Muller) which attaches exif information to
* a GimpImage, and if there is infoprmation available at save
* time, writes it out. No modification of the exif data is
* currently possible.
*/
#include "config.h" /* configure cares about HAVE_PROGRESSIVE_JPEG */
#include <glib.h> /* We want glib.h first because of some
......@@ -147,6 +158,10 @@
#include <jpeglib.h>
#include <jerror.h>
#ifdef HAVE_EXIF
#include <libexif/exif-data.h>
#endif /* HAVE_EXIF */
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
......@@ -281,6 +296,9 @@ static gchar *image_comment = NULL;
static GtkWidget *restart_markers_scale = NULL;
static GtkWidget *restart_markers_label = NULL;
#ifdef HAVE_EXIF
static ExifData *exif_data = NULL;
#endif /* HAVE_EXIF */
MAIN ()
......@@ -425,6 +443,11 @@ run (gchar *name,
break;
}
#ifdef HAVE_EXIF
exif_data_unref (exif_data);
exif_data = NULL;
#endif /* HAVE_EXIF */
g_free (image_comment);
image_comment = NULL;
......@@ -435,6 +458,15 @@ run (gchar *name,
gimp_parasite_free (parasite);
}