about summary refs log tree commit diff
path: root/converter/other/pstopnm.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-09-29 02:44:42 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-09-29 02:44:42 +0000
commitacf1c3cd5f989ff0e2a3895f35875c918b4c3eb8 (patch)
treeeec649bf9126f527b3b1f5bb128121e8280a49cc /converter/other/pstopnm.c
parent84c6e11810783388e5be22ab80a5dafe523f20db (diff)
downloadnetpbm-mirror-acf1c3cd5f989ff0e2a3895f35875c918b4c3eb8.tar.gz
netpbm-mirror-acf1c3cd5f989ff0e2a3895f35875c918b4c3eb8.tar.xz
netpbm-mirror-acf1c3cd5f989ff0e2a3895f35875c918b4c3eb8.zip
Release 10.47.70
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@3345 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/pstopnm.c')
-rw-r--r--converter/other/pstopnm.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/converter/other/pstopnm.c b/converter/other/pstopnm.c
index ba1470b0..0e91ad9c 100644
--- a/converter/other/pstopnm.c
+++ b/converter/other/pstopnm.c
@@ -275,9 +275,13 @@ computeSizeResBlind(unsigned int   const xmax,
                     unsigned int * const xresP,
                     unsigned int * const yresP) {
 
-    *xresP = *yresP = MIN(xmax * 72 / imageWidth, 
-                          ymax * 72 / imageHeight);
-    
+    if (imageWidth == 0 || imageHeight == 0) {
+        *xresP = *yresP = 72;
+    } else {
+        *xresP = *yresP = MIN(xmax * 72 / imageWidth,
+                              ymax * 72 / imageHeight);
+    }
+
     if (nocrop) {
         *xsizeP = xmax;
         *ysizeP = ymax;
@@ -335,10 +339,13 @@ computeSizeRes(struct cmdlineInfo const cmdline,
         *xresP = *yresP = cmdline.dpi;
         *xsizeP = (int) (cmdline.dpi * sx / 72 + 0.5);
         *ysizeP = (int) (cmdline.dpi * sy / 72 + 0.5);
-    } else  if (cmdline.xsize || cmdline.ysize)
+    } else  if (cmdline.xsize || cmdline.ysize) {
+        if (sx == 0 || sy == 0)
+            pm_error("Input image is zero size; we cannot satisfy your "
+                     "produce your requested output dimensions");
         computeSizeResFromSizeSpec(cmdline.xsize, cmdline.ysize, sx, sy,
                                    xsizeP, ysizeP, xresP, yresP);
-    else 
+    } else
         computeSizeResBlind(cmdline.xmax, cmdline.ymax, sx, sy, cmdline.nocrop,
                             xsizeP, ysizeP, xresP, yresP);
 
@@ -886,7 +893,12 @@ main(int argc, char ** argv) {
 
     computeSizeRes(cmdline, orientation, bordered_box, 
                    &xsize, &ysize, &xres, &yres);
-    
+
+    if (xres == 0)
+        xres = 1;
+    if (yres == 0)
+        yres = 1;
+
     pstrans = computePstrans(bordered_box, orientation,
                              xsize, ysize, xres, yres);