gimp r25480 - in trunk: . plug-ins/jpeg
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25480 - in trunk: . plug-ins/jpeg
- Date: Mon, 14 Apr 2008 09:16:37 +0100 (BST)
Author: neo
Date: Mon Apr 14 09:16:37 2008
New Revision: 25480
URL: http://svn.gnome.org/viewvc/gimp?rev=25480&view=rev
Log:
2008-04-14 Sven Neumann <sven gimp org>
* plug-ins/jpeg/jpeg.h
* plug-ins/jpeg/jpeg-exif.c
* plug-ins/jpeg/jpeg-load.c: rotate the thumbnail according to
the
EXIF orientation as required by the updated thumbnail spec.
Modified:
trunk/ChangeLog
trunk/plug-ins/jpeg/jpeg-exif.c
trunk/plug-ins/jpeg/jpeg-load.c
trunk/plug-ins/jpeg/jpeg.h
Modified: trunk/plug-ins/jpeg/jpeg-exif.c
==============================================================================
--- trunk/plug-ins/jpeg/jpeg-exif.c (original)
+++ trunk/plug-ins/jpeg/jpeg-exif.c Mon Apr 14 09:16:37 2008
@@ -54,7 +54,7 @@
#define JPEG_EXIF_ROTATE_PARASITE "exif-orientation-rotate"
-static gboolean jpeg_exif_rotate_query (gint32 image_ID);
+static gboolean jpeg_exif_rotate_query_dialog (gint32 image_ID);
/* Replacement for exif_data_new_from_file() to work around
@@ -87,9 +87,7 @@
jpeg_exif_get_orientation (ExifData *exif_data)
{
ExifEntry *entry;
- gint byte_order;
-
- byte_order = exif_data_get_byte_order (exif_data);
+ gint byte_order = exif_data_get_byte_order (exif_data);
/* get orientation and rotate image accordingly if necessary */
if ((entry = exif_content_get_entry (exif_data->ifd[EXIF_IFD_0],
@@ -97,6 +95,7 @@
{
return exif_get_short (entry->data, byte_order);
}
+
return 0;
}
@@ -181,55 +180,26 @@
/* should set components configuration, don't know how */
/*
- *remove entries that don't apply to jpeg
- *(may have come from tiff or raw)
- */
- gimp_exif_data_remove_entry(exif_data, EXIF_IFD_0, EXIF_TAG_COMPRESSION);
- gimp_exif_data_remove_entry(exif_data, EXIF_IFD_0, EXIF_TAG_IMAGE_WIDTH);
- gimp_exif_data_remove_entry(exif_data, EXIF_IFD_0, EXIF_TAG_IMAGE_LENGTH);
- gimp_exif_data_remove_entry(exif_data, EXIF_IFD_0, EXIF_TAG_BITS_PER_SAMPLE);
- gimp_exif_data_remove_entry(exif_data, EXIF_IFD_0, EXIF_TAG_SAMPLES_PER_PIXEL);
- gimp_exif_data_remove_entry(exif_data, EXIF_IFD_0, EXIF_TAG_PHOTOMETRIC_INTERPRETATION);
- gimp_exif_data_remove_entry(exif_data, EXIF_IFD_0, EXIF_TAG_STRIP_OFFSETS);
- gimp_exif_data_remove_entry(exif_data, EXIF_IFD_0, EXIF_TAG_PLANAR_CONFIGURATION);
- gimp_exif_data_remove_entry(exif_data, EXIF_IFD_0, EXIF_TAG_YCBCR_SUB_SAMPLING);
+ * remove entries that don't apply to jpeg
+ * (may have come from tiff or raw)
+ */
+ gimp_exif_data_remove_entry (exif_data, EXIF_IFD_0, EXIF_TAG_COMPRESSION);
+ gimp_exif_data_remove_entry (exif_data, EXIF_IFD_0, EXIF_TAG_IMAGE_WIDTH);
+ gimp_exif_data_remove_entry (exif_data, EXIF_IFD_0, EXIF_TAG_IMAGE_LENGTH);
+ gimp_exif_data_remove_entry (exif_data, EXIF_IFD_0, EXIF_TAG_BITS_PER_SAMPLE);
+ gimp_exif_data_remove_entry (exif_data, EXIF_IFD_0, EXIF_TAG_SAMPLES_PER_PIXEL);
+ gimp_exif_data_remove_entry (exif_data, EXIF_IFD_0, EXIF_TAG_PHOTOMETRIC_INTERPRETATION);
+ gimp_exif_data_remove_entry (exif_data, EXIF_IFD_0, EXIF_TAG_STRIP_OFFSETS);
+ gimp_exif_data_remove_entry (exif_data, EXIF_IFD_0, EXIF_TAG_PLANAR_CONFIGURATION);
+ gimp_exif_data_remove_entry (exif_data, EXIF_IFD_0, EXIF_TAG_YCBCR_SUB_SAMPLING);
/* should set thumbnail attributes */
}
-
void
jpeg_exif_rotate (gint32 image_ID,
gint orientation)
{
- GimpParasite *parasite;
- gboolean query = load_interactive;
-
- if (orientation < 2 || orientation > 8)
- return;
-
- parasite = gimp_parasite_find (JPEG_EXIF_ROTATE_PARASITE);
-
- if (parasite)
- {
- if (strncmp (gimp_parasite_data (parasite), "yes",
- gimp_parasite_data_size (parasite)) == 0)
- {
- query = FALSE;
- }
- else if (strncmp (gimp_parasite_data (parasite), "no",
- gimp_parasite_data_size (parasite)) == 0)
- {
- gimp_parasite_free (parasite);
- return;
- }
-
- gimp_parasite_free (parasite);
- }
-
- if (query && ! jpeg_exif_rotate_query (image_ID))
- return;
-
switch (orientation)
{
case 1: /* standard orientation, do nothing */
@@ -269,13 +239,48 @@
jpeg_swap_original_settings (image_ID);
break;
- default: /* can't happen */
+ default: /* shouldn't happen */
break;
}
}
+void
+jpeg_exif_rotate_query (gint32 image_ID,
+ gint orientation)
+{
+ GimpParasite *parasite;
+ gboolean query = load_interactive;
+
+ if (orientation < 2 || orientation > 8)
+ return;
+
+ parasite = gimp_parasite_find (JPEG_EXIF_ROTATE_PARASITE);
+
+ if (parasite)
+ {
+ if (strncmp (gimp_parasite_data (parasite), "yes",
+ gimp_parasite_data_size (parasite)) == 0)
+ {
+ query = FALSE;
+ }
+ else if (strncmp (gimp_parasite_data (parasite), "no",
+ gimp_parasite_data_size (parasite)) == 0)
+ {
+ gimp_parasite_free (parasite);
+ return;
+ }
+
+ gimp_parasite_free (parasite);
+ }
+
+ if (query && ! jpeg_exif_rotate_query_dialog (image_ID))
+ return;
+
+ jpeg_exif_rotate (image_ID, orientation);
+}
+
static gboolean
-jpeg_exif_rotate_query (gint32 image_ID)
+jpeg_exif_rotate_query_dialog (gint32 image_ID)
{
GtkWidget *dialog;
GtkWidget *hbox;
Modified: trunk/plug-ins/jpeg/jpeg-load.c
==============================================================================
--- trunk/plug-ins/jpeg/jpeg-load.c (original)
+++ trunk/plug-ins/jpeg/jpeg-load.c Mon Apr 14 09:16:37 2008
@@ -231,6 +231,8 @@
{
image_ID = gimp_image_new (cinfo.output_width, cinfo.output_height,
image_type);
+
+ gimp_image_undo_disable (image_ID);
gimp_image_set_filename (image_ID, filename);
jpeg_load_resolution (image_ID, &cinfo);
@@ -462,13 +464,13 @@
/* Detach from the drawable and add it to the image.
*/
- if (!preview)
+ if (! preview)
gimp_drawable_detach (drawable);
+
gimp_image_add_layer (image_ID, layer_ID, 0);
#ifdef HAVE_EXIF
- if (orientation > 0)
- jpeg_exif_rotate (image_ID, orientation);
+ jpeg_exif_rotate_query (image_ID, orientation);
#endif
return image_ID;
@@ -610,6 +612,7 @@
gint tile_height;
gint scanlines;
gint i, start, end;
+ gint orientation;
my_src_ptr src;
FILE *infile;
@@ -619,8 +622,10 @@
if (! ((exif_data) && (exif_data->data) && (exif_data->size > 0)))
return -1;
+ orientation = jpeg_exif_get_orientation (exif_data);
+
cinfo.err = jpeg_std_error (&jerr.pub);
- jerr.pub.error_exit = my_error_exit;
+ jerr.pub.error_exit = my_error_exit;
jerr.pub.output_message = my_output_message;
gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
@@ -745,6 +750,8 @@
image_ID = gimp_image_new (cinfo.output_width, cinfo.output_height,
image_type);
+
+ gimp_image_undo_disable (image_ID);
gimp_image_set_filename (image_ID, filename);
jpeg_load_resolution (image_ID, &cinfo);
@@ -882,6 +889,8 @@
exif_data = NULL;
}
+ jpeg_exif_rotate (image_ID, orientation);
+
return image_ID;
}
Modified: trunk/plug-ins/jpeg/jpeg.h
==============================================================================
--- trunk/plug-ins/jpeg/jpeg.h (original)
+++ trunk/plug-ins/jpeg/jpeg.h Mon Apr 14 09:16:37 2008
@@ -82,5 +82,8 @@
void jpeg_exif_rotate (gint32 image_ID,
gint orientation);
+void jpeg_exif_rotate_query (gint32 image_ID,
+ gint orientation);
+
#endif /* HAVE_EXIF */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]