Commit 546a1676 authored by Paolo Bacchilega's avatar Paolo Bacchilega Committed by Paolo Bacchilega

Fixes zoom keybinding (bug #345339).

2006-10-19  Paolo Bacchilega  <paobac@cvs.gnome.org>

	* src/gth-browser.c (key_press_cb): Fixes zoom keybinding (bug #345339).

	* src/rotation-utils.c (write_orientation_field):
	* src/rotation-utils.h:
	* src/dlg-reset-exif.c (apply_transformation):
	* src/dlg-jpegtran.c (apply_transformation): Fixes tag updating when
	multiple IFDs have orientation tag.

	* libgthumb/jpegutils/jpegtran.h:
	* libgthumb/jpegutils/jpegtran.c (jpegtran): Adds support for the trim mode.

	* libgthumb/typedefs.h: Adds comments to the GthTransform typedef, to
	explain its purpose.

	* README: Updates the README file to reflect new intltool minimum
	requirement.

	Patch by Jef Driesen, Michael Chudobiak.
parent 4d32406c
2006-10-19 Paolo Bacchilega <paobac@cvs.gnome.org>
* src/gth-browser.c (key_press_cb): Fixes zoom keybinding (bug #345339).
* src/rotation-utils.c (write_orientation_field):
* src/rotation-utils.h:
* src/dlg-reset-exif.c (apply_transformation):
* src/dlg-jpegtran.c (apply_transformation): Fixes tag updating when
multiple IFDs have orientation tag.
* libgthumb/jpegutils/jpegtran.h:
* libgthumb/jpegutils/jpegtran.c (jpegtran): Adds support for the trim mode.
* libgthumb/typedefs.h: Adds comments to the GthTransform typedef, to
explain its purpose.
* README: Updates the README file to reflect new intltool minimum
requirement.
Patch by Jef Driesen, Michael Chudobiak.
2006-10-14 Paolo Bacchilega <paobac@cvs.gnome.org>
* data/gthumb.schemas.in:
......
......@@ -96,6 +96,7 @@ Compiling
* libgnomeprintui version >= 2.6.0
* libbonobo version >= 2.6.0
* libbonoboui version >= 2.6.0
* intltool version >= 0.35.0
* libexif version >= 0.6.9
* libjpeg
......
......@@ -99,6 +99,7 @@ int
jpegtran (char *input_filename,
char *output_filename,
JXFORM_CODE transformation,
gboolean trim,
GError **error)
{
struct jpeg_decompress_struct srcinfo;
......@@ -111,7 +112,7 @@ jpegtran (char *input_filename,
FILE *output_file;
transformoption.transform = transformation;
transformoption.trim = FALSE;
transformoption.trim = trim;
transformoption.force_grayscale = FALSE;
/* Initialize the JPEG decompression object with default error
......
......@@ -32,6 +32,7 @@
int jpegtran (char *input_filename,
char *output_filename,
JXFORM_CODE transformation,
gboolean trim,
GError **error);
#endif /* JPEGTRAN_H */
......@@ -213,6 +213,14 @@ typedef enum { /*< skip >*/
GTH_TRANSFORM_TRANSVERSE, /* transpose across UR-to-LL axis (= rotate_90 + flip_v) */
GTH_TRANSFORM_ROTATE_270 /* 270-degree clockwise */
} GthTransform;
/* The GthTransform numeric values range from 1 to 8, corresponding to
the valid range of Exif orientation tags. The name associated with each
numeric valid describes the data transformation required that will allow
the orientation value to be reset to "1" without changing the displayed image.
GthTransform and ExifShort values are interchangeably in a number of places.
The main difference is that ExifShort can have a value of zero, corresponding
to an error or an absence of an Exif orientation tag. See bug 361913 for
additional details. */
typedef enum { /*< skip >*/
......
......@@ -261,22 +261,22 @@ apply_transformation (DialogData *data,
gdk_pixbuf_get_file_info (get_file_path_from_uri (path), &width, &height);
orientation = get_exif_tag_short (path, EXIF_TAG_ORIENTATION);;
orientation = get_exif_tag_short (path, EXIF_TAG_ORIENTATION);
if (orientation != 0) {
data->transform = get_next_transformation (orientation, data->transform);
if (! eel_gconf_get_boolean (PREF_ROTATE_RESET_EXIF_ORIENTATION, TRUE)) {
/* Just change the exif orientation tag, and save the file */
update_orientation_field (path, data->transform);
write_orientation_field (path, data->transform);
}
else if ((height % 8 == 0) && (width % 8 == 0)) {
/* Do a physical transform if requested and if the dimensions are
* multiples of the jpeg mcu (8) */
data->transform = get_next_transformation (orientation, data->transform);
apply_transformation_jpeg (window, path, data->transform);
}
else {
/* Just change the exif orientation tag, and save the file */
_gtk_info_dialog_run (window, _("This image can not be physically transformed without image distortion, because its dimensions are not multiples of 8. Instead, gThumb will change the Exif orientation tag to accomplish the rotation without image distortion. To avoid this warning in the future, disable the \"Apply physical transform\" option in the rotation dialog."));
update_orientation_field (path, data->transform);
write_orientation_field (path, data->transform);
}
}
else {
......
......@@ -121,7 +121,7 @@ apply_transformation (DialogData *data,
g_free (dir);
gnome_vfs_get_file_info (path, &info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS|GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
reset_orientation_field (path);
write_orientation_field (path, GTH_TRANSFORM_NONE);
gnome_vfs_set_file_info (path, &info, GNOME_VFS_SET_FILE_INFO_PERMISSIONS|GNOME_VFS_SET_FILE_INFO_OWNER);
......
......@@ -3065,7 +3065,12 @@ key_press_cb (GtkWidget *widget,
}
}
if ((event->state & GDK_CONTROL_MASK) || (event->state & GDK_MOD1_MASK))
if (((event->state & GDK_CONTROL_MASK)
/* Let pass the ctrl+keypad_add and ctrl+keypad_subtract. */
&& (event->keyval != GDK_KP_Add) && (event->keyval != GDK_KP_Subtract)
) || (event->state & GDK_MOD1_MASK))
return FALSE;
sel_not_null = gth_file_view_selection_not_null (priv->file_list->view);
......
......@@ -50,8 +50,10 @@ read_orientation_field (const char *path)
return GTH_TRANSFORM_NONE;
}
void
reset_orientation_field (const char *path)
write_orientation_field (const char *path,
GthTransform transform)
{
JPEGData *jdata;
ExifData *edata;
......@@ -82,7 +84,7 @@ reset_orientation_field (const char *path)
if (entry != NULL) {
ExifByteOrder byte_order;
byte_order = exif_data_get_byte_order (edata);
exif_set_short (entry->data, byte_order, GTH_TRANSFORM_NONE);
exif_set_short (entry->data, byte_order, transform);
}
}
......@@ -144,7 +146,7 @@ apply_transformation_jpeg (GtkWindow *win,
break;
}
if (jpegtran ((char*)path, tmp, transf, &err) != 0) {
if (jpegtran ((char*)path, tmp, transf, FALSE, &err) != 0) {
g_free (tmp);
if (err != NULL)
_gtk_error_dialog_from_gerror_run (win, &err);
......@@ -165,7 +167,7 @@ apply_transformation_jpeg (GtkWindow *win,
if ((rot_type == GTH_TRANSFORM_ROTATE_90) ||
(rot_type == GTH_TRANSFORM_ROTATE_270))
swap_xy_exif_fields (path);
reset_orientation_field (path);
write_orientation_field (path, GTH_TRANSFORM_NONE);
}
g_free (e1);
......@@ -314,56 +316,6 @@ get_mirror_or_flip_part(GthTransform transform)
}
void
update_orientation_field (const char *path,
GthTransform transform)
{
JPEGData *jdata;
ExifData *edata;
unsigned int i;
path = get_file_path_from_uri (path);
if (path == NULL)
return;
jdata = jpeg_data_new_from_file (path);
if (jdata == NULL)
return;
edata = jpeg_data_get_exif_data (jdata);
if (edata == NULL) {
jpeg_data_unref (jdata);
return;
}
for (i = 0; i < EXIF_IFD_COUNT; i++) {
ExifContent *content = edata->ifd[i];
ExifEntry *entry;
if ((content == NULL) || (content->count == 0))
continue;
entry = exif_content_get_entry (content, EXIF_TAG_ORIENTATION);
if (entry != NULL) {
ExifByteOrder byte_order;
ExifShort value;
byte_order = exif_data_get_byte_order (edata);
value = exif_get_short (entry->data, byte_order);
value = get_next_transformation(value, transform);
exif_set_short (entry->data, byte_order, value);
}
}
jpeg_data_save_file (jdata, path);
exif_data_unref (edata);
jpeg_data_unref (jdata);
}
gboolean
swap_fields (ExifContent *content,
ExifTag tag1,
......
......@@ -29,9 +29,6 @@
#include "gth-exif-utils.h"
void apply_transformation_exif (GtkWindow *win,
const char *filename,
GthTransform transform);
void apply_transformation_jpeg (GtkWindow *win,
const char *filename,
GthTransform transform);
......@@ -45,8 +42,7 @@ GthTransform get_rotation_part (GthTransform transform);
GthTransform get_mirror_part (GthTransform transform);
GthTransform read_orientation_field (const char *path);
void reset_orientation_field (const char *path);
void update_orientation_field (const char *filename,
void write_orientation_field (const char *filename,
GthTransform transform);
gboolean swap_fields (ExifContent *content,
......
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