[gimp] Issue #4068: default pixel density should be 72.0 for loaded images.



commit fef9b1d2a3456df80761f060b3e41ae967a3d913
Author: Jehan <jehan girinstud io>
Date:   Sat Oct 12 16:38:05 2019 +0200

    Issue #4068: default pixel density should be 72.0 for loaded images.
    
    New images should obviously still default to the template pixel density
    (defaulting to 300.0 PPI when no specific template is selected).
    
    Loaded images though should use a more conservative default of 72 PPI,
    first because this is what other software defaults to when no density is
    set (so we should keep consistent when possible), and this is also what
    the Exif standard (I checked both last version 2.32, and older 2.3)
    recommends when no resolution is set.
    
    Technically we differentiate a loaded from a newly created image by
    whether or not an imported_file has been set. Of course, any explicitly
    set resolution will always override whatever default.

 app/core/gimpimage-private.h |  1 +
 app/core/gimpimage.c         | 24 ++++++++++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpimage-private.h b/app/core/gimpimage-private.h
index a2ae25691c..0c77b9a281 100644
--- a/app/core/gimpimage-private.h
+++ b/app/core/gimpimage-private.h
@@ -45,6 +45,7 @@ struct _GimpImagePrivate
   gdouble            xresolution;           /*  image x-res, in dpi          */
   gdouble            yresolution;           /*  image y-res, in dpi          */
   GimpUnit           resolution_unit;       /*  resolution unit              */
+  gboolean           resolution_set;        /*  resolution explicitly set    */
   GimpImageBaseType  base_type;             /*  base gimp_image type         */
   GimpPrecision      precision;             /*  image's precision            */
   GimpLayerMode      new_layer_mode;        /*  default mode of new layers   */
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 93b63c7e4b..9c59b68a18 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -723,6 +723,7 @@ gimp_image_init (GimpImage *image)
   private->height              = 0;
   private->xresolution         = 1.0;
   private->yresolution         = 1.0;
+  private->resolution_set      = FALSE;
   private->resolution_unit     = GIMP_UNIT_INCH;
   private->base_type           = GIMP_RGB;
   private->precision           = GIMP_PRECISION_U8_NON_LINEAR;
@@ -2287,6 +2288,24 @@ gimp_image_set_imported_file (GimpImage *image,
     {
       gimp_object_name_changed (GIMP_OBJECT (image));
     }
+
+  if (! private->resolution_set)
+    {
+      /* Unlike new files (which follow technological progress and will
+       * use higher default resolution, or explicitly chosen templates),
+       * imported files have a more backward-compatible value.
+       *
+       * 72 PPI is traditionnally the default value when none other had
+       * been explicitly set (for instance it is the default when no
+       * resolution metadata was set in Exif version 2.32, and below,
+       * standard). This historical value will only ever apply to loaded
+       * images. New images will continue having more modern or
+       * templated defaults.
+       */
+      private->xresolution     = 72.0;
+      private->yresolution     = 72.0;
+      private->resolution_unit = GIMP_UNIT_INCH;
+    }
 }
 
 /**
@@ -2788,8 +2807,9 @@ gimp_image_set_resolution (GimpImage *image,
       gimp_image_undo_push_image_resolution (image,
                                              C_("undo-type", "Change Image Resolution"));
 
-      private->xresolution = xresolution;
-      private->yresolution = yresolution;
+      private->xresolution    = xresolution;
+      private->yresolution    = yresolution;
+      private->resolution_set = TRUE;
 
       gimp_image_resolution_changed (image);
       gimp_image_size_changed_detailed (image,


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