Commit e04b8a9f authored by William Skaggs's avatar William Skaggs

Bill Skaggs <weskaggs@primate.ucdavis.edu>

	* libgthumb/gth-exif-utils.c
	* libgthumb/gth-exif-utils.h
	* libgthumb/jpegutils/.cvsignore
	* libgthumb/jpegutils/Makefile.am
	* libgthumb/jpegutils/README
	* libgthumb/jpegutils/jpeg-data.c
	* libgthumb/jpegutils/jpeg-data.h
	* libgthumb/jpegutils/jpeg-marker.c
	* libgthumb/jpegutils/jpeg-marker.h
	* libgthumb/jpegutils/jpegtran.c
	* libgthumb/jpegutils/jpegtran.h
	* libgthumb/jpegutils/transupp.c
	* libgthumb/jpegutils/transupp.h: new files

	* configure.in
	* components/catalog-view/Makefile.am
	* components/image-viewer/Makefile.am
	* data/gthumb.schemas.in
	* data/glade/gthumb_preferences.glade
	* data/glade/gthumb_tools.glade
	* doc/C/gthumb.xml
	* libgthumb/Makefile.am
	* libgthumb/gthumb-module.c
	* libgthumb/image-loader.c
	* libgthumb/preferences.h
	* src/Makefile.am
	* src/dlg-jpegtran.c
	* src/dlg-jpegtran.h
	* src/dlg-photo-importer.c
	* src/dlg-preferences.c
	* src/gth-browser-ui.h
	* src/gth-window-actions-callbacks.c
	* src/gth-window-actions-callbacks.h
	* src/gth-window-actions-entries.h
	* src/rotation-utils.c
	* src/rotation-utils.h: modified files.

	Committed patches listed in comment #106 of bug #343867,
	as follows:

	patch -p0 < gthumb-exif-v3.patch
	patch -p0 < gthumb_reset_exif_orientation_v2.patch
	patch -p0 < importer.patch
	patch -p0 < gthumb_rotate_v3.patch
	patch -p1 < gthumb-20061006-exif-rotate.patch
	patch -p1 < delete-checkbox-v2.patch

	This is development aimed at improving gthumb's handling
	of exif metadata.
parent 7fbf1c61
2006-10-01 Bill Skaggs <weskaggs@primate.ucdavis.edu>
2006-10-06 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* libgthumb/gth-exif-utils.c
* libgthumb/gth-exif-utils.h
* libgthumb/jpegutils/.cvsignore
* libgthumb/jpegutils/Makefile.am
* libgthumb/jpegutils/README
* libgthumb/jpegutils/jpeg-data.c
* libgthumb/jpegutils/jpeg-data.h
* libgthumb/jpegutils/jpeg-marker.c
* libgthumb/jpegutils/jpeg-marker.h
* libgthumb/jpegutils/jpegtran.c
* libgthumb/jpegutils/jpegtran.h
* libgthumb/jpegutils/transupp.c
* libgthumb/jpegutils/transupp.h: new files
* configure.in
* components/catalog-view/Makefile.am
* components/image-viewer/Makefile.am
* data/gthumb.schemas.in
* data/glade/gthumb_preferences.glade
* data/glade/gthumb_tools.glade
* doc/C/gthumb.xml
* libgthumb/Makefile.am
* libgthumb/gthumb-module.c
* libgthumb/image-loader.c
* libgthumb/preferences.h
* src/Makefile.am
* src/dlg-jpegtran.c
* src/dlg-jpegtran.h
* src/dlg-photo-importer.c
* src/dlg-preferences.c
* src/gth-browser-ui.h
* src/gth-window-actions-callbacks.c
* src/gth-window-actions-callbacks.h
* src/gth-window-actions-entries.h
* src/rotation-utils.c
* src/rotation-utils.h: modified files.
Committed patches listed in comment #106 of bug #343867,
as follows:
patch -p0 < gthumb-exif-v3.patch
patch -p0 < gthumb_reset_exif_orientation_v2.patch
patch -p0 < importer.patch
patch -p0 < gthumb_rotate_v3.patch
patch -p1 < gthumb-20061006-exif-rotate.patch
patch -p1 < delete-checkbox-v2.patch
This is development aimed at improving gthumb's handling
of exif metadata.
2006-10-06 Bill Skaggs <weskaggs@primate.ucdavis.edu>
Initiating "exif-testing" branch. Testing to make sure commit
goes to the right branch, and not to HEAD.
......
......@@ -29,6 +29,7 @@ gthumb_catalog_view_SOURCES = \
gthumb_catalog_view_LDADD = \
$(COMPONENT_LIBS) \
$(EXIF_LIBS) \
$(JPEG_LIBS) \
$(IPTCDATA_LIBS) \
$(TIFF_LIBS) \
......
......@@ -34,6 +34,7 @@ gthumb_image_viewer_SOURCES = \
gthumb_image_viewer_LDADD = \
$(COMPONENT_LIBS) \
$(EXIF_LIBS) \
$(JPEG_LIBS) \
$(IPTCDATA_LIBS) \
$(TIFF_LIBS) \
......
......@@ -330,9 +330,9 @@ po/Makefile.in
libgthumb/Makefile
libgthumb/cursors/Makefile
libgthumb/icons/Makefile
libgthumb/jpegutils/Makefile
src/Makefile
src/icons/Makefile
src/jpegutils/Makefile
components/Makefile
components/image-viewer/Makefile
components/catalog-view/Makefile
......
......@@ -785,6 +785,147 @@
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox62">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkHBox" id="hbox122">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="label189">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;To rotate images with Exif orientation tag support:&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox123">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label190">
<property name="visible">True</property>
<property name="label" translatable="yes"> </property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox63">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkRadioButton" id="radio_exif_use_orientation_tag">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Adjust orientation tag. Leave image data unchanged.</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_exif_use_image_transform">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Adjust image data. Reset orientation tag to top-left.</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">radio_exif_use_orientation_tag</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
......
......@@ -762,25 +762,6 @@
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="j_from_exif_checkbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Adjust photo _orientation</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
......
......@@ -95,7 +95,20 @@
</locale>
</schema>
<!-- Broswer -->
<schema>
<key>/schemas/apps/gthumb/general/use_exif_orientation</key>
<applyto>/apps/gthumb/general/use_exif_orientation</applyto>
<owner>gthumb</owner>
<type>bool</type>
<default>false</default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<!-- Browser -->
<schema>
<key>/schemas/apps/gthumb/browser/show_hidden_files</key>
......
......@@ -1988,13 +1988,6 @@
<para>
Click on <guibutton>Apply</guibutton> to apply the changes.
</para>
<para>
If you check the <guilabel>Adjust photo orientation</guilabel>
option, an attempt is done to read the current orientation from
the photo data embedded in the image, if the orientation data is
found an automatic rotation is applied to the image in order to
visualize the image in the right orientation.
</para>
<para>
If you check the <guilabel>Apply to all images</guilabel>
option, the rotation is applied to the
......
SUBDIRS = icons cursors
DIST_SUBDIRS = icons cursors
SUBDIRS = icons cursors jpegutils
DIST_SUBDIRS = icons cursors jpegutils
if ENABLE_DEPRECATIONS
DISABLE_DEPRECATED = -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGNOME_VFS_DISABLE_DEPRECATED -DGNOME_DISABLE_DEPRECATED -DBONOBO_DISABLE_DEPRECATED
......@@ -10,6 +10,7 @@ endif
gladedir = $(datadir)/gthumb/glade
INCLUDES = \
$(EXIF_CFLAGS) \
$(GTHUMB_CFLAGS) \
-DGTHUMB_MODULEDIR=\""$(libdir)/gthumb/modules"\" \
-DGTHUMB_GLADEDIR=\""$(gladedir)"\" \
......@@ -44,6 +45,7 @@ HEADER_FILES = \
gnome-print-font-picker.h \
gnome-print-font-dialog.h \
gstringlist.h \
gth-exif-utils.h \
gth-image-list.h \
gth-iviewer.h \
gth-file-list.h \
......@@ -100,6 +102,7 @@ libgthumb_la_SOURCES = \
gnome-print-font-picker.c \
gnome-print-font-dialog.c \
gstringlist.c \
gth-exif-utils.c \
gth-pixbuf-op.c \
gth-image-list.c \
gth-iviewer.c \
......@@ -129,9 +132,11 @@ libgthumb_la_SOURCES = \
thumb-loader.c
libgthumb_la_LIBADD = \
$(EXIF_LIBS) \
$(TIFF_LIBS) \
$(GTHUMB_LIBS) \
$(IPTCDATA_LIBS)
$(IPTCDATA_LIBS) \
$(top_builddir)/libgthumb/jpegutils/libgthumb-jpegutils.la
gthumb-marshal.h: gthumb-marshal.list $(GLIB_GENMARSHAL)
$(GLIB_GENMARSHAL) $(top_srcdir)/libgthumb/gthumb-marshal.list --header --prefix=gthumb_marshal > $(top_srcdir)/libgthumb/gthumb-marshal.h
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2003 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
#include <config.h>
#ifdef HAVE_LIBEXIF
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <glib.h>
#include "file-utils.h"
#include "gth-exif-utils.h"
char *
get_exif_tag (const char *filename,
ExifTag etag)
{
ExifData *edata;
unsigned int i, j;
filename = get_file_path_from_uri (filename);
if (filename == NULL)
return g_strdup ("-");
edata = exif_data_new_from_file (filename);
if (edata == NULL)
return g_strdup ("-");
for (i = 0; i < EXIF_IFD_COUNT; i++) {
ExifContent *content = edata->ifd[i];
if (! edata->ifd[i] || ! edata->ifd[i]->count)
continue;
for (j = 0; j < content->count; j++) {
ExifEntry *e = content->entries[j];
if (! content->entries[j])
continue;
if (e->tag == etag) {
const char *value;
char *retval = NULL;
value = get_exif_entry_value (e);
if (value != NULL)
retval = g_locale_to_utf8 (value, -1, 0, 0, 0);
else
retval = g_strdup ("-");
exif_data_unref (edata);
return retval;
}
}
}
exif_data_unref (edata);
return g_strdup ("-");
}
ExifShort
get_exif_tag_short (const char *filename,
ExifTag etag)
{
ExifData *edata;
unsigned int i, j;
filename = get_file_path_from_uri (filename);
if (filename == NULL)
return 0;
edata = exif_data_new_from_file (filename);
if (edata == NULL)
return 0;
for (i = 0; i < EXIF_IFD_COUNT; i++) {
ExifContent *content = edata->ifd[i];
if (! edata->ifd[i] || ! edata->ifd[i]->count)
continue;
for (j = 0; j < content->count; j++) {
ExifEntry *e = content->entries[j];
if (! content->entries[j])
continue;
if (e->tag == etag) {
ExifByteOrder o;
ExifShort retval = 0;
o = exif_data_get_byte_order (e->parent->parent);
if (e->data != NULL)
retval = exif_get_short (e->data, o);
exif_data_unref (edata);
return retval;
}
}
}
exif_data_unref (edata);
return 0;
}
time_t
get_exif_time (const char *filename)
{
ExifData *edata;
unsigned int i, j;
time_t time = 0;
struct tm tm = { 0, };
filename = get_file_path_from_uri (filename);
if (filename == NULL)
return (time_t)0;
edata = exif_data_new_from_file (filename);
if (edata == NULL)
return (time_t)0;
for (i = 0; i < EXIF_IFD_COUNT; i++) {
ExifContent *content = edata->ifd[i];
if (! edata->ifd[i] || ! edata->ifd[i]->count)
continue;
for (j = 0; j < content->count; j++) {
ExifEntry *e = content->entries[j];
char *data;
if (! content->entries[j])
continue;
if ((e->tag != EXIF_TAG_DATE_TIME) &&
(e->tag != EXIF_TAG_DATE_TIME_ORIGINAL) &&
(e->tag != EXIF_TAG_DATE_TIME_DIGITIZED))
continue;
if (e->data == NULL)
continue;
if (strlen ((char*)e->data) < 10)
continue;
data = g_strdup ((char*)e->data);
data[4] = data[7] = data[10] = '\0';
tm.tm_year = atoi (data) - 1900;
tm.tm_mon = atoi (data + 5) - 1;
tm.tm_mday = atoi (data + 8);
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;
tm.tm_isdst = -1;
if (strlen ((char*)e->data) > 10) {
data[13] = data[16] = '\0';
tm.tm_hour = atoi (data + 11);
tm.tm_min = atoi (data + 14);
tm.tm_sec = atoi (data + 17);
}
time = mktime (&tm);
g_free (data);
break;
}
}
exif_data_unref (edata);
return time;
}
char *
get_exif_aperture_value (const char *filename)
{
ExifData *edata;
unsigned int i, j;
filename = get_file_path_from_uri (filename);
if (filename == NULL)
return g_strdup ("-");
edata = exif_data_new_from_file (filename);
if (edata == NULL)
return g_strdup ("-");
for (i = 0; i < EXIF_IFD_COUNT; i++) {
ExifContent *content = edata->ifd[i];
if (! edata->ifd[i] || ! edata->ifd[i]->count)
continue;
for (j = 0; j < content->count; j++) {
ExifEntry *e = content->entries[j];
const char *value = NULL;
char *retval = NULL;
if (! content->entries[j])
continue;
if ((e->tag != EXIF_TAG_APERTURE_VALUE) &&
(e->tag != EXIF_TAG_FNUMBER))
continue;
value = get_exif_entry_value (e);
if (value)
retval = g_locale_to_utf8 (value, -1, 0, 0, 0);
else
retval = g_strdup ("-");
exif_data_unref (edata);
return retval;
}
}
exif_data_unref (edata);
return g_strdup ("-");
}
gboolean
have_exif_time (const char *filename)
{
return get_exif_time (filename) != (time_t)0;
}
#define VALUE_LEN 1024
const char *
get_exif_entry_value (ExifEntry *entry)
{
#ifdef HAVE_LIBEXIF_0_5
return exif_entry_get_value (entry);
#else
char value[VALUE_LEN + 1];
return exif_entry_get_value (entry, value, VALUE_LEN);
#endif
}
ExifData *
load_exif_data (const char *filename)
{
JPEGData *jdata = NULL;
ExifData *exif_data = NULL;
filename = get_file_path_from_uri (filename);
if (filename == NULL)
return NULL;
jdata = jpeg_data_new_from_file (filename);
if (jdata == NULL)
return NULL;
exif_data = jpeg_data_get_exif_data (jdata);
jpeg_data_unref (jdata);
return exif_data;
}
void
save_exif_data (const char *filename,
ExifData *edata)
{
JPEGData *jdata;
filename = get_file_path_from_uri (filename);
if (filename == NULL)
return;
jdata = jpeg_data_new_from_file (filename);
if (jdata == NULL)
return;
if (edata != NULL)
jpeg_data_set_exif_data (jdata, edata);
jpeg_data_save_file (jdata, filename);
jpeg_data_unref (jdata);
}
void
copy_exif_data (const char *src,
const char *dest)
{
ExifData *edata;
if (!image_is_jpeg (src) || !image_is_jpeg (dest))
return;
src = get_file_path_from_uri (src);
if (src == NULL)
return;
dest = get_file_path_from_uri (dest);
if (dest == NULL)
return;
edata = exif_data_new_from_file (src);
if (edata == NULL)
return;
save_exif_data (dest, edata);
exif_data_unref (edata);
}
#endif /* HAVE_LIBEXIF */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* GThumb
*
* Copyright (C) 2003 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*/
#ifndef EXIF_UTILS_H
#define EXIF_UTILS_H
#include <config.h>
#ifdef HAVE_LIBEXIF
#include <libexif/exif-data.h>
#include <libexif/exif-content.h>
#include <libexif/exif-entry.h>
#include <libexif/exif-utils.h>
#include "jpegutils/jpeg-data.h"
typedef enum { /*< skip >*/
GTH_EXIF_ORIENTATION_NONE = 0,
GTH_EXIF_ORIENTATION_TOP_LEFT,
GTH_EXIF_ORIENTATION_TOP_RIGHT,
GTH_EXIF_ORIENTATION_BOTTOM_RIGHT,