about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/HISTORY5
-rw-r--r--editor/pnmremap.c14
2 files changed, 12 insertions, 7 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 036305ef..cc1df24a 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -6,6 +6,11 @@ CHANGE HISTORY
 
 not yet  BJH  Release 10.88.00
 
+              pnmremap: Don't output any part of the image if program fails
+              because the maxval of input and map file do not match, in a
+              case where matching maxval is required, i.e. the user specified
+              -firstisdefault or -missingcolor.
+
               ppmhist: sort secondarily by RGB with -sort=frequency, so
               output is repeatable.
 
diff --git a/editor/pnmremap.c b/editor/pnmremap.c
index 0038f4d7..0c0096ba 100644
--- a/editor/pnmremap.c
+++ b/editor/pnmremap.c
@@ -1043,13 +1043,6 @@ copyRaster(struct pam *   const inpamP,
     inrow  = pnm_allocpamrow(inpamP);
     outrow = pnm_allocpamrow(&workpam);
 
-    if (outpamP->maxval != inpamP->maxval && defaultColor)
-        pm_error("The maxval of the colormap (%u) is not equal to the "
-                 "maxval of the input image (%u).  This is allowable only "
-                 "if you are doing an approximate mapping (i.e. you don't "
-                 "specify -firstisdefault or -missingcolor)",
-                 (unsigned int)outpamP->maxval, (unsigned int)inpamP->maxval);
-
     selectDepthAdjustment(inpamP, outpamP->depth, &depthAdjustment);
 
     usehash = TRUE;
@@ -1120,6 +1113,13 @@ remap(FILE *             const ifP,
         outpam.width  = inpam.width;
         outpam.height = inpam.height;
 
+        if (outpam.maxval != inpam.maxval && defaultColor)
+            pm_error("The maxval of the colormap (%u) is not equal to the "
+                     "maxval of the input image (%u).  This is allowable only "
+                     "if you are doing an approximate mapping (i.e. you don't "
+                     "specify -firstisdefault or -missingcolor)",
+                     (unsigned int)outpam.maxval, (unsigned int)inpam.maxval);
+
         pnm_writepaminit(&outpam);
 
         /* Set up so input buffers have extra space as needed to