[gimp] plug-ins: trust the TIFF's resolution over its metadata's resolution



commit 7752873adda3a86dead47ad96e5d02c74bf06177
Author: Michael Natterer <mitch gimp org>
Date:   Sun Oct 27 18:52:46 2013 +0100

    plug-ins: trust the TIFF's resolution over its metadata's resolution
    
    This also sortof addresses bug #691231, but fixes the issue only
    indirectly by not perferring the EXIF resolution.

 plug-ins/file-jpeg/jpeg-load.c |   11 ++++++++---
 plug-ins/file-jpeg/jpeg-load.h |    1 +
 plug-ins/file-jpeg/jpeg-save.c |    6 +++---
 plug-ins/file-jpeg/jpeg.c      |    8 +++++++-
 4 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/plug-ins/file-jpeg/jpeg-load.c b/plug-ins/file-jpeg/jpeg-load.c
index 6a7ace6..4273437 100644
--- a/plug-ins/file-jpeg/jpeg-load.c
+++ b/plug-ins/file-jpeg/jpeg-load.c
@@ -42,7 +42,7 @@
 #include "jpeg-settings.h"
 #include "jpeg-load.h"
 
-static void  jpeg_load_resolution           (gint32    image_ID,
+static gboolean  jpeg_load_resolution       (gint32    image_ID,
                                              struct jpeg_decompress_struct
                                                        *cinfo);
 
@@ -61,6 +61,7 @@ gint32
 load_image (const gchar  *filename,
             GimpRunMode   runmode,
             gboolean      preview,
+            gboolean     *resolution_loaded,
             GError      **error)
 {
   gint32 volatile  image_ID;
@@ -289,7 +290,11 @@ load_image (const gchar  *filename,
             }
         }
 
-        jpeg_load_resolution (image_ID, &cinfo);
+      if (jpeg_load_resolution (image_ID, &cinfo))
+        {
+          if (resolution_loaded)
+            *resolution_loaded = TRUE;
+        }
 
       /* if we found any comments, then make a parasite for them */
       if (comment_buffer && comment_buffer->len)
@@ -416,7 +421,7 @@ load_image (const gchar  *filename,
   return image_ID;
 }
 
-static void
+static gboolean
 jpeg_load_resolution (gint32                         image_ID,
                       struct jpeg_decompress_struct *cinfo)
 {
diff --git a/plug-ins/file-jpeg/jpeg-load.h b/plug-ins/file-jpeg/jpeg-load.h
index 0ecdc8c..d4e61b0 100644
--- a/plug-ins/file-jpeg/jpeg-load.h
+++ b/plug-ins/file-jpeg/jpeg-load.h
@@ -21,6 +21,7 @@
 gint32 load_image           (const gchar  *filename,
                              GimpRunMode   runmode,
                              gboolean      preview,
+                             gboolean     *resolution_loaded,
                              GError      **error);
 
 gint32 load_thumbnail_image (GFile         *file,
diff --git a/plug-ins/file-jpeg/jpeg-save.c b/plug-ins/file-jpeg/jpeg-save.c
index d4058ca..f68f3d2 100644
--- a/plug-ins/file-jpeg/jpeg-save.c
+++ b/plug-ins/file-jpeg/jpeg-save.c
@@ -151,7 +151,7 @@ background_error_exit (j_common_ptr cinfo)
 static gboolean
 background_jpeg_save (PreviewPersistent *pp)
 {
-  gint    yend;
+  gint yend;
 
   if (pp->abort_me || (pp->cinfo.next_scanline >= pp->cinfo.image_height))
     {
@@ -206,10 +206,10 @@ background_jpeg_save (PreviewPersistent *pp)
           gtk_label_set_text (GTK_LABEL (preview_size), text);
           g_free (text);
 
-         g_object_unref (file);
+          g_object_unref (file);
 
           /* and load the preview */
-          load_image (pp->file_name, GIMP_RUN_NONINTERACTIVE, TRUE, NULL);
+          load_image (pp->file_name, GIMP_RUN_NONINTERACTIVE, TRUE, NULL, NULL);
         }
 
       /* we cleanup here (load_image doesn't run in the background) */
diff --git a/plug-ins/file-jpeg/jpeg.c b/plug-ins/file-jpeg/jpeg.c
index 39e15ed..1f0b3ae 100644
--- a/plug-ins/file-jpeg/jpeg.c
+++ b/plug-ins/file-jpeg/jpeg.c
@@ -198,6 +198,8 @@ run (const gchar      *name,
 
   if (strcmp (name, LOAD_PROC) == 0)
     {
+      gboolean resolution_loaded = FALSE;
+
       switch (run_mode)
         {
         case GIMP_RUN_INTERACTIVE:
@@ -210,7 +212,8 @@ run (const gchar      *name,
           break;
         }
 
-      image_ID = load_image (param[1].data.d_string, run_mode, FALSE, &error);
+      image_ID = load_image (param[1].data.d_string, run_mode, FALSE,
+                             &resolution_loaded, &error);
 
       if (image_ID != -1)
         {
@@ -224,6 +227,9 @@ run (const gchar      *name,
             {
               GimpMetadataLoadFlags flags = GIMP_METADATA_LOAD_ALL;
 
+              if (resolution_loaded)
+                flags &= ~GIMP_METADATA_LOAD_RESOLUTION;
+
               gimp_image_metadata_load_finish (image_ID, "image/jpeg",
                                                metadata, flags,
                                                load_interactive);


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