about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-10-05 01:39:48 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-10-05 01:39:48 +0000
commit3ec8202a6f3f5b758ba15261aaff11d712eb11fe (patch)
tree30d82d4b7a0e44b2a66f087da821fbfd86c23ba6
parentc5c692af190eabf5f927a8139fc5f101dbbfb439 (diff)
downloadnetpbm-mirror-3ec8202a6f3f5b758ba15261aaff11d712eb11fe.tar.gz
netpbm-mirror-3ec8202a6f3f5b758ba15261aaff11d712eb11fe.tar.xz
netpbm-mirror-3ec8202a6f3f5b758ba15261aaff11d712eb11fe.zip
Add -reportonly
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3702 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY4
-rw-r--r--editor/pnmpad.c40
2 files changed, 35 insertions, 9 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 9ddb6f83..7447303f 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -8,7 +8,9 @@ CHANGE HISTORY
 
 not yet   BJH  Release 10.89.00
 
-               pamfind: fix typo in message.
+               pnmpad: Add -reportonly.
+
+               pamfind: Fix typo in message.
 
 19.09.28  BJH  Release 10.88.00
 
diff --git a/editor/pnmpad.c b/editor/pnmpad.c
index 9c7a77e5..55cdcd6c 100644
--- a/editor/pnmpad.c
+++ b/editor/pnmpad.c
@@ -38,6 +38,7 @@ struct cmdlineInfo {
     unsigned int mwidth;
     unsigned int mheight;
     unsigned int white;     /* >0: pad white; 0: pad black */
+    unsigned int reportonly;
     unsigned int verbose;
 };
 
@@ -86,14 +87,16 @@ parseCommandLine(int argc, const char ** argv,
             &yalignSpec,           0);
     OPTENT3(0,   "valign",    OPT_FLOAT,   &cmdlineP->yalign,
             &yalignSpec,           0);
-    OPTENT3(0,   "black",     OPT_FLAG,    NULL,
-            &blackOpt,           0);
     OPTENT3(0,   "mwidth",    OPT_UINT,    &cmdlineP->mwidth,
             &mwidthSpec,         0);
     OPTENT3(0,   "mheight",   OPT_UINT,    &cmdlineP->mheight,
             &mheightSpec,        0);
+    OPTENT3(0,   "black",     OPT_FLAG,    NULL,
+            &blackOpt,           0);
     OPTENT3(0,   "white",     OPT_FLAG,    NULL,
             &cmdlineP->white,    0);
+    OPTENT3(0,   "reportonly", OPT_FLAG,   NULL,
+            &cmdlineP->reportonly,   0);
     OPTENT3(0,   "verbose",   OPT_FLAG,    NULL,
             &cmdlineP->verbose,  0);
 
@@ -489,6 +492,23 @@ computePadSizes(struct cmdlineInfo const cmdline,
 
 
 static void
+reportPadSizes(int          const inCols,
+               int          const inRows,
+               unsigned int const lpad,
+               unsigned int const rpad,
+               unsigned int const tpad,
+               unsigned int const bpad) {
+
+    unsigned int const outCols = inCols + lpad + rpad;
+    unsigned int const outRows = inRows + tpad + bpad;
+ 
+    printf("%u %u %u %u %u %u\n", lpad, rpad, tpad, bpad, outCols, outRows);
+
+}
+
+
+
+static void
 padPbm(FILE *       const ifP,
        unsigned int const cols,
        unsigned int const rows,
@@ -636,12 +656,16 @@ main(int argc, const char ** argv) {
 
     newcols = cols + lpad + rpad;
 
-    if (PNM_FORMAT_TYPE(format) == PBM_TYPE)
-        padPbm(ifP, cols, rows, format, newcols, lpad, rpad, tpad, bpad,
-               !!cmdline.white);
-    else
-        padGeneral(ifP, cols, rows, maxval, format, 
-                   newcols, lpad, rpad, tpad, bpad, !!cmdline.white);
+    if (cmdline.reportonly)
+        reportPadSizes(cols, rows, lpad, rpad, tpad, bpad);
+    else {
+        if (PNM_FORMAT_TYPE(format) == PBM_TYPE)
+            padPbm(ifP, cols, rows, format, newcols, lpad, rpad, tpad, bpad,
+                   !!cmdline.white);
+        else
+            padGeneral(ifP, cols, rows, maxval, format,
+                       newcols, lpad, rpad, tpad, bpad, !!cmdline.white);
+    }
 
     pm_close(ifP);