about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-04-06 19:33:44 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-04-06 19:33:44 +0000
commit9ad490d118b9c9b38415ddbc5155c9d4f62109bd (patch)
treef7ae6ecd6514efa41e9eb37157978274a286f877
parentaad47e743f21763ac13b73eb927ad7d001254572 (diff)
downloadnetpbm-mirror-9ad490d118b9c9b38415ddbc5155c9d4f62109bd.tar.gz
netpbm-mirror-9ad490d118b9c9b38415ddbc5155c9d4f62109bd.tar.xz
netpbm-mirror-9ad490d118b9c9b38415ddbc5155c9d4f62109bd.zip
Release 10.86.01
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3592 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY5
-rw-r--r--editor/pnmcrop.c38
-rw-r--r--version.mk2
3 files changed, 26 insertions, 19 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index e936536b..929008f8 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -3,6 +3,11 @@ Netpbm.
 
 CHANGE HISTORY 
 --------------
+19.04.06 BJH  Release 10.86.01
+
+              pnmcrop: fix bug: incorrect identification of background with
+              -bgcolor and PBM or PGM image.  Always present (-bgcolor was
+              introduced in Netpbm 10.86 (March 2019).
 
 19.03.30 BJH  Release 10.86.00
 
diff --git a/editor/pnmcrop.c b/editor/pnmcrop.c
index bea7a1bf..3f414e1b 100644
--- a/editor/pnmcrop.c
+++ b/editor/pnmcrop.c
@@ -387,17 +387,15 @@ backgroundColorFmName(const char * const colorName,
 /*----------------------------------------------------------------------------
    The color indicated by 'colorName'.
 
-   If the image is PGM we allow only shades of gray.  If it is PBM, we allow
-   only pure black and pure white.
+   The return value is based on maxval 'maxval' and format 'format'.
+
+   Abort the program if 'colorName' names a color that cannot be represented
+   in format 'format'.
 
    Development note: It would be logical to relax the above restriction when
    -closeness is specified.  Implementation is harder than it seems because of
    the -margin option.  It is unlikely that there is demand for this feature.
    If really necessary, the user can convert the input image to PPM.
-
-   Adjust xel for maxval and image type (PPM, PGM, PBM) of the image to
-   examine.  For PGM and PBM, only the blue plane is given a value.  So set
-   the other two to zero.  (This is necessary for making comparisons).
 -----------------------------------------------------------------------------*/
     pixel const backgroundColor    =
         ppm_parsecolor(colorName, maxval);
@@ -416,18 +414,22 @@ backgroundColorFmName(const char * const colorName,
 
     xel backgroundXel;
 
-    backgroundXel = pnm_pixeltoxel(backgroundColor);  /* initial value */
-
-    /* Adjust backgroundXel to match input image format, if necessary */
-
-    if (PBM_FORMAT_TYPE(format) == PBM_TYPE && hasGray)
-        pm_error("Invalid color specified: '%s'.  "
-                 "Image has no intermediate levels of gray.",
-                 colorName);
-
-    if (PPM_FORMAT_TYPE(format) != PPM_TYPE && hasColor)
-        pm_error("Invalid color specified: '%s'.  "
-                 "Image does not have color.", colorName);
+    if (PPM_FORMAT_TYPE(format)) {
+        backgroundXel = pnm_pixeltoxel(backgroundColor);
+    } else {
+        /* Derive PBM or PGM xel from pixel 'backgroundColor' */
+        if (hasColor)
+            pm_error("Invalid color specified: '%s'. "
+                     "Image does not have color.", colorName);
+        else {
+            if (PBM_FORMAT_TYPE(format) == PBM_TYPE && hasGray)
+                pm_error("Invalid color specified: '%s'. "
+                         "Image has no intermediate levels of gray.",
+                         colorName);
+            else
+                PNM_ASSIGN1(backgroundXel, backgroundColor.r);
+        }
+    }
 
     return backgroundXel;
 }
diff --git a/version.mk b/version.mk
index dc0d192a..8a482446 100644
--- a/version.mk
+++ b/version.mk
@@ -1,3 +1,3 @@
 NETPBM_MAJOR_RELEASE = 10
 NETPBM_MINOR_RELEASE = 86
-NETPBM_POINT_RELEASE = 0
+NETPBM_POINT_RELEASE = 1