Re: [Gimp-developer] EXIF in JPEGs and TIFFs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Lutz Müller wrote:
EXIF information in JPEGs using libexif. This patch never got into the
GIMP nor was updated to 1.3.x as

Did some 'sledgehammer hacking' to get the old exif patch to work under GIMP 1.3.12. It's attached as a text file. I assume absolutely no responsibility for it. It's allll Lutz's fault. ;-)


jas
--
Jason Van Patten
AOL IM: Jason VP

diff -BPcpr gimp-1.3.12/acclocal.h gimp-1.3.12-exif/acclocal.h
*** gimp-1.3.12/acclocal.h	Wed Dec 31 19:00:00 1969
--- gimp-1.3.12-exif/acclocal.h	Wed Mar 19 09:47:26 2003
***************
*** 0 ****
--- 1,2 ----
+ #undef HAVE_EXIF
+ 
diff -BPcpr gimp-1.3.12/configure.in gimp-1.3.12-exif/configure.in
*** gimp-1.3.12/configure.in	Sat Feb  8 05:00:12 2003
--- gimp-1.3.12-exif/configure.in	Wed Mar 19 09:47:21 2003
*************** AC_SUBST(gimpplugindir)
*** 1073,1078 ****
--- 1073,1108 ----
  AC_SUBST(gimpsysconfdir)
  AC_SUBST(localedir)
  
+ dnl ---------------------------------------------------------------------------
+ dnl libexif-gtk: JPEG files can contain EXIF data. If libexif-gtk is installed
+ dnl              on the system, gimp can use it to read this data from 
+ dnl              JPEG files and save it (if the file is saved again in
+ dnl              the JPEG format). In addition, gimp can offer the user the
+ dnl              possibility to edit (!) EXIF data.
+ dnl ---------------------------------------------------------------------------
+ exif_msg="no (http://www.sourceforge.net/projects/libexif)"
+ try_exif=true
+ AC_ARG_WITH(exif, [  --without-exif          Don't use libexif],[
+        if test x$withval = xno; then
+                try_exif=false
+        fi])
+ if $try_exif; then
+        AC_PATH_PROG(PKG_CONFIG,pkg-config)
+        if test -n "${PKG_CONFIG}"; then
+                AC_MSG_CHECKING([for libexif-gtk])
+                if ${PKG_CONFIG} --exists libexif-gtk > /dev/null 2>&1; then
+                        EXIF_CFLAGS=`$PKG_CONFIG --cflags libexif-gtk`
+                        EXIF_LIBS=`$PKG_CONFIG --libs libexif-gtk`
+                        exif_msg=yes
+                        AC_DEFINE(HAVE_EXIF,1,[Define EXIF])
+                        fi
+                AC_MSG_RESULT($exif_msg)
+        else
+                AC_WARN([Not searching for libexif - pkg-config not found.])
+        fi
+ fi
+ AC_SUBST(EXIF_CFLAGS)
+ AC_SUBST(EXIF_LIBS)
  
  ############################
  # Some defines for the build
diff -BPcpr gimp-1.3.12/plug-ins/common/Makefile.am gimp-1.3.12-exif/plug-ins/common/Makefile.am
*** gimp-1.3.12/plug-ins/common/Makefile.am	Wed Jan 29 05:26:48 2003
--- gimp-1.3.12-exif/plug-ins/common/Makefile.am	Wed Mar 19 09:47:35 2003
*************** EXTRA_DIST = \
*** 15,20 ****
--- 15,21 ----
  INCLUDES = \
  	-I$(top_srcdir)		\
  	$(GTK_CFLAGS)		\
+ 	$(EXIF_CFLAGS)		\
  	$(X_CFLAGS)		\
  	-I$(includedir)
  
*************** jpeg_LDADD = \
*** 913,918 ****
--- 914,920 ----
  	$(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la	\
  	$(top_builddir)/libgimpbase/libgimpbase-$(LT_RELEASE).la	\
  	$(LIBJPEG)							\
+ 	$(EXIF_LIBS)							\
  	$(GTK_LIBS)							\
  	$(INTLLIBS)
  
diff -BPcpr gimp-1.3.12/plug-ins/common/jpeg.c gimp-1.3.12-exif/plug-ins/common/jpeg.c
*** gimp-1.3.12/plug-ins/common/jpeg.c	Mon Feb 17 18:31:58 2003
--- gimp-1.3.12-exif/plug-ins/common/jpeg.c	Wed Mar 19 09:47:42 2003
***************
*** 146,151 ****
--- 146,155 ----
  #include <jpeglib.h>
  #include <jerror.h>
  
+ #ifdef HAVE_EXIF
+ #include <libexif-gtk/gtk-exif-browser.h>
+ #endif
+ 
  #include <libgimp/gimp.h>
  #include <libgimp/gimpui.h>
  
*************** static JpegSaveInterface jsint =
*** 278,284 ****
  static gchar     *image_comment         = NULL;
  static GtkWidget *restart_markers_scale = NULL;
  static GtkWidget *restart_markers_label = NULL;
! 
  
  MAIN ()
  
--- 282,290 ----
  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
  
  MAIN ()
  
*************** run (gchar      *name,
*** 424,430 ****
  	default:
  	  break;
  	}
!       
        g_free (image_comment);
        image_comment = NULL;
      
--- 430,440 ----
  	default:
  	  break;
  	}
! #ifdef HAVE_EXIF
!       exif_data_unref (exif_data);
!       exif_data = NULL;
! #endif
!  
        g_free (image_comment);
        image_comment = NULL;
      
*************** run (gchar      *name,
*** 434,439 ****
--- 444,457 ----
  	  image_comment = g_strdup (parasite->data);
  	  gimp_parasite_free (parasite);
  	}
+ #ifdef HAVE_EXIF
+       parasite = gimp_image_parasite_find (orig_image_ID, "exif-data");
+       if (parasite)
+        {
+           exif_data = exif_data_new_from_data (parasite->data, parasite->size);
+           gimp_parasite_free (parasite);
+        }
+ #endif /* HAVE_EXIF */
  
        if (!image_comment)
          image_comment = gimp_get_default_comment ();
*************** load_image (gchar       *filename, 
*** 718,723 ****
--- 736,747 ----
    gint     i, start, end;
  
    GimpParasite * volatile comment_parasite = NULL;
+ #ifdef HAVE_EXIF
+   GimpParasite * exif_parasite = NULL;
+   ExifData *exif_data = NULL;
+   unsigned char *exif_buf = NULL;
+   unsigned int exif_buf_len = 0;
+ #endif
  
    /* We set up the normal JPEG error routines. */
    cinfo.err = jpeg_std_error (&jerr.pub);
*************** load_image (gchar       *filename, 
*** 1060,1065 ****
--- 1084,1102 ----
            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 ("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;
  }
*************** save_image (gchar    *filename,
*** 1188,1193 ****
--- 1225,1234 ----
    gboolean  has_alpha;
    gint      rowstride, yend;
    gint      i, j;
+ #ifdef HAVE_EXIF
+   unsigned char *exif_buf;
+   unsigned int   exif_buf_len;
+ #endif
  
    drawable = gimp_drawable_get (drawable_ID);
    drawable_type = gimp_drawable_type (drawable_ID);
*************** save_image (gchar    *filename,
*** 1390,1395 ****
--- 1431,1444 ----
     * Pass TRUE unless you are very sure of what you're doing.
     */
    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)
*************** save_dialog (void)
*** 1561,1572 ****
--- 1610,1623 ----
    GtkWidget     *dlg;
    GtkWidget     *vbox;
    GtkWidget     *main_vbox;
+   GtkWidget	*exif_vbox;
    GtkWidget     *label;
    GtkWidget     *scale;
    GtkWidget     *frame;
    GtkWidget     *table;
    GtkWidget     *toggle;
    GtkWidget     *abox;
+   GtkWidget 	*notebook;
    GtkObject     *scale_data;
  
    GtkWidget     *progressive;
*************** save_dialog (void)
*** 1582,1587 ****
--- 1633,1639 ----
    GtkTextBuffer *text_buffer;
    GtkWidget     *com_frame;
    GtkWidget     *scrolled_window;
+   GtkWidget 	*browser;
  
    GtkWidget     *prv_frame;
    GimpImageType  dtype;
*************** save_dialog (void)
*** 1602,1612 ****
                      G_CALLBACK (save_close_callback),
                      NULL);
  
!   main_vbox = gtk_vbox_new (FALSE, 4);
!   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6);
!   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox,
  		      TRUE, TRUE, 0);
    gtk_widget_show (main_vbox);
  
    /* sg - preview */
    prv_frame = gtk_frame_new (_("Image Preview"));
--- 1654,1689 ----
                      G_CALLBACK (save_close_callback),
                      NULL);
  
!   notebook = gtk_notebook_new ();
!   gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
!   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), notebook,
  		      TRUE, TRUE, 0);
+   gtk_widget_show (notebook);
+ 
+   main_vbox = gtk_vbox_new (FALSE, 4);
+   gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 3);
+   label = gtk_label_new (_("JPEG Settings"));
+   gtk_notebook_append_page (GTK_NOTEBOOK (notebook), main_vbox, label);
    gtk_widget_show (main_vbox);
+   gtk_widget_show (label);
+ 
+   exif_vbox = gtk_vbox_new (FALSE, 4);
+   gtk_container_set_border_width (GTK_CONTAINER (exif_vbox), 3);
+   label = gtk_label_new (_("EXIF Data"));
+   gtk_notebook_append_page (GTK_NOTEBOOK (notebook), exif_vbox, label);
+   gtk_widget_show (exif_vbox);
+   gtk_widget_show (label);
+ 
+ #ifdef HAVE_EXIF
+   browser = gtk_exif_browser_new ();
+   if (!exif_data)
+     exif_data = exif_data_new ();
+   gtk_exif_browser_set_data (GTK_EXIF_BROWSER (browser), exif_data);
+ #else
+   browser = gtk_label_new (_("No EXIF support available."));
+ #endif
+   gtk_box_pack_start (GTK_BOX (exif_vbox), browser, TRUE, TRUE, 0);
+   gtk_widget_show (browser);
  
    /* sg - preview */
    prv_frame = gtk_frame_new (_("Image Preview"));

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux