diff --git a/src/modules/Image/encodings/png.c b/src/modules/Image/encodings/png.c
index b50f3611472ea66141819024df5d975e09ca4e6e..2edb0bd262c9d477932fb6c592e414689819a01f 100644
--- a/src/modules/Image/encodings/png.c
+++ b/src/modules/Image/encodings/png.c
@@ -1,5 +1,5 @@
 #include "global.h"
-RCSID("$Id: png.c,v 1.28 1999/11/14 22:16:09 mast Exp $");
+RCSID("$Id: png.c,v 1.29 2000/03/25 18:18:21 per Exp $");
 
 #include "image_machine.h"
 
@@ -898,7 +898,7 @@ static int _png_write_rgb(rgb_group *w1,
 	 switch (bpp)
 	 {
 	    case 8:
-	       if (n>len/3) n=len/3;
+	       if (n>len/4) n=len/4;
 	       while (n)
 	       {
 		  d1->r=*(s++);
@@ -911,7 +911,7 @@ static int _png_write_rgb(rgb_group *w1,
 	       }
 	       break;
 	    case 16:
-	       if (n>len/6) n=len/6;
+	       if (n>len/8) n=len/8;
 	       while (n)
 	       {
 		  d1->r=*(s++);