diff --git a/.gitignore b/.gitignore
index 6c496c0..f4510f8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,3 +18,15 @@
/netpbm-10.90.00.tar.xz
/netpbm-10.92.00.tar.xz
/netpbm-10.93.00.tar.xz
+/netpbm-10.94.05.tar.xz
+/netpbm-10.95.00.tar.xz
+/netpbm-10.96.00.tar.xz
+/netpbm-10.97.00.tar.xz
+/netpbm-10.99.00.tar.xz
+/netpbm-11.00.00.tar.xz
+/netpbm-11.01.00.tar.xz
+/netpbm-11.02.00.tar.xz
+/netpbm-11.09.00.tar.xz
+/netpbm-11.10.00.tar.xz
+/netpbm-11.12.00.tar.xz
+/netpbm-11.13.00.tar.xz
diff --git a/fix.patch b/fix.patch
new file mode 100644
index 0000000..b3c3cb9
--- /dev/null
+++ b/fix.patch
@@ -0,0 +1,1336 @@
+diff --git a/analyzer/pgmtexture.c b/analyzer/pgmtexture.c
+index c69643e..2e09dde 100644
+--- a/analyzer/pgmtexture.c
++++ b/analyzer/pgmtexture.c
+@@ -54,6 +54,7 @@ vector(unsigned int const nl,
+
+ assert(nh >= nl);
+
++ overflow_add(nh - nl, 1);
+ MALLOCARRAY(v, (unsigned) (nh - nl + 1));
+
+ if (v == NULL)
+@@ -85,6 +86,7 @@ matrix (unsigned int const nrl,
+ assert(nrh >= nrl);
+
+ /* allocate pointers to rows */
++ overflow_add(nrh - nrl, 1);
+ MALLOCARRAY(m, (unsigned) (nrh - nrl + 1));
+ if (m == NULL)
+ pm_error("Unable to allocate memory for a matrix.");
+@@ -93,6 +95,7 @@ matrix (unsigned int const nrl,
+
+ assert (nch >= ncl);
+
++ overflow_add(nch - ncl, 1);
+ /* allocate rows and set pointers to them */
+ for (i = nrl; i <= nrh; ++i) {
+ MALLOCARRAY(m[i], (unsigned) (nch - ncl + 1));
+diff --git a/converter/other/gemtopnm.c b/converter/other/gemtopnm.c
+index 6bbfcc0..24199cb 100644
+--- a/converter/other/gemtopnm.c
++++ b/converter/other/gemtopnm.c
+@@ -106,6 +106,7 @@ main(argc, argv)
+
+ pnm_writepnminit( stdout, cols, rows, MAXVAL, type, 0 );
+
++ overflow_add(cols, padright);
+ {
+ /* allocate input row data structure */
+ int plane;
+diff --git a/converter/other/jpegtopnm.c b/converter/other/jpegtopnm.c
+index 98552c0..311298c 100644
+--- a/converter/other/jpegtopnm.c
++++ b/converter/other/jpegtopnm.c
+@@ -862,6 +862,8 @@ convertImage(FILE * const ofP,
+ /* Calculate output image dimensions so we can allocate space */
+ jpeg_calc_output_dimensions(cinfoP);
+
++ overflow2(cinfoP->output_width, cinfoP->output_components);
++
+ /* Start decompressor */
+ jpeg_start_decompress(cinfoP);
+
+diff --git a/converter/other/pbmtopgm.c b/converter/other/pbmtopgm.c
+index 817fb5b..8baaa57 100644
+--- a/converter/other/pbmtopgm.c
++++ b/converter/other/pbmtopgm.c
+@@ -60,6 +60,7 @@ main(int argc, char *argv[]) {
+
+
+ outrow = pgm_allocrow(cols) ;
++ overflow2(width, height);
+ maxval = MIN(PGM_OVERALLMAXVAL, width*height);
+ pgm_writepgminit(stdout, cols, rows, maxval, 0) ;
+
+diff --git a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c
+index b7b942b..52be0e4 100644
+--- a/converter/other/pnmtoddif.c
++++ b/converter/other/pnmtoddif.c
+@@ -629,6 +629,7 @@ main(int argc, char *argv[]) {
+ switch (PNM_FORMAT_TYPE(format)) {
+ case PBM_TYPE:
+ ip.bits_per_pixel = 1;
++ overflow_add(cols, 7);
+ ip.bytes_per_line = (cols + 7) / 8;
+ ip.spectral = 2;
+ ip.components = 1;
+@@ -644,6 +645,7 @@ main(int argc, char *argv[]) {
+ ip.polarity = 2;
+ break;
+ case PPM_TYPE:
++ overflow2(cols, 3);
+ ip.bytes_per_line = 3 * cols;
+ ip.bits_per_pixel = 24;
+ ip.spectral = 5;
+diff --git a/converter/other/pnmtojpeg.c b/converter/other/pnmtojpeg.c
+index e345831..39038f8 100644
+--- a/converter/other/pnmtojpeg.c
++++ b/converter/other/pnmtojpeg.c
+@@ -605,8 +605,10 @@ read_scan_script(j_compress_ptr const cinfo,
+ data, but if you want to compress multiple images you'd
+ want JPOOL_PERMANENT.
+ */
++ overflow2(nscans, sizeof(jpeg_scan_info));
+ const unsigned int scan_info_size = nscans * sizeof(jpeg_scan_info);
+- jpeg_scan_info * const scan_info =
++ const jpeg_scan_info * scan_info;
++ scan_info =
+ (jpeg_scan_info *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
+ scan_info_size);
+@@ -938,6 +940,8 @@ compute_rescaling_array(JSAMPLE ** const rescale_p, const pixval maxval,
+ const long half_maxval = maxval / 2;
+ long val;
+
++ overflow_add(maxval, 1);
++ overflow2(maxval+1, sizeof(JSAMPLE));
+ *rescale_p = (JSAMPLE *)
+ (cinfo.mem->alloc_small) ((j_common_ptr) &cinfo, JPOOL_IMAGE,
+ (size_t) (((long) maxval + 1L) *
+@@ -1016,6 +1020,7 @@ convert_scanlines(struct jpeg_compress_struct * const cinfo_p,
+ */
+
+ /* Allocate the libpnm output and compressor input buffers */
++ overflow2(cinfo_p->image_width, cinfo_p->input_components);
+ buffer = (*cinfo_p->mem->alloc_sarray)
+ ((j_common_ptr) cinfo_p, JPOOL_IMAGE,
+ (unsigned int) cinfo_p->image_width * cinfo_p->input_components,
+diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c
+index 45d856d..5b04eeb 100644
+--- a/converter/other/pnmtops.c
++++ b/converter/other/pnmtops.c
+@@ -294,17 +294,21 @@ parseCommandLine(int argc, const char ** argv,
+ validateCompDimension(width, 72, "-width value");
+ validateCompDimension(height, 72, "-height value");
+
++ overflow2(width, 72);
+ cmdlineP->width = width * 72;
++ overflow2(height, 72);
+ cmdlineP->height = height * 72;
+
+ if (imagewidthSpec) {
+ validateCompDimension(imagewidth, 72, "-imagewidth value");
++ overflow2(imagewidth, 72);
+ cmdlineP->imagewidth = imagewidth * 72;
+ }
+ else
+ cmdlineP->imagewidth = 0;
+ if (imageheightSpec) {
+- validateCompDimension(imagewidth, 72, "-imageheight value");
++ validateCompDimension(imageheight, 72, "-imageheight value");
++ overflow2(imageheight, 72);
+ cmdlineP->imageheight = imageheight * 72;
+ }
+ else
+diff --git a/converter/other/rletopnm.c b/converter/other/rletopnm.c
+index 97f271d..72b63d3 100644
+--- a/converter/other/rletopnm.c
++++ b/converter/other/rletopnm.c
+@@ -19,6 +19,8 @@
+ * If you modify this software, you should include a notice giving the
+ * name of the person performing the modification, the date of modification,
+ * and the reason for such modification.
++ *
++ * 2002-12-19: Fix maths wrapping bugs. Alan Cox
+ */
+ /*
+ * rletopnm - A conversion program to convert from Utah's "rle" image format
+diff --git a/converter/other/sirtopnm.c b/converter/other/sirtopnm.c
+index fafcc91..9fe49d0 100644
+--- a/converter/other/sirtopnm.c
++++ b/converter/other/sirtopnm.c
+@@ -69,6 +69,7 @@ char* argv[];
+ }
+ break;
+ case PPM_TYPE:
++ overflow3(cols, rows, 3);
+ picsize = cols * rows * 3;
+ planesize = cols * rows;
+ if ( !( sirarray = (unsigned char*) malloc( picsize ) ) )
+diff --git a/converter/other/tifftopnm.c b/converter/other/tifftopnm.c
+index 05493e7..7ea59fd 100644
+--- a/converter/other/tifftopnm.c
++++ b/converter/other/tifftopnm.c
+@@ -1372,6 +1372,7 @@ convertRasterByRows(pnmOut * const pnmOutP,
+ if (scanbuf == NULL)
+ pm_error("can't allocate memory for scanline buffer");
+
++ overflow2(cols,spp);
+ MALLOCARRAY(samplebuf, cols * spp);
+ if (samplebuf == NULL)
+ pm_error("can't allocate memory for row buffer");
+diff --git a/converter/other/xwdtopnm.c b/converter/other/xwdtopnm.c
+index a74da34..4d26a31 100644
+--- a/converter/other/xwdtopnm.c
++++ b/converter/other/xwdtopnm.c
+@@ -210,6 +210,10 @@ processX10Header(X10WDFileHeader * const h10P,
+ *colorsP = pnm_allocrow(2);
+ PNM_ASSIGN1((*colorsP)[0], 0);
+ PNM_ASSIGN1((*colorsP)[1], *maxvalP);
++ overflow_add(h10P->pixmap_width, 15);
++ if(h10P->pixmap_width < 0)
++ pm_error("assert: negative width");
++ overflow2((((h10P->pixmap_width + 15) / 16) * 16 - h10P->pixmap_width), 8);
+ *padrightP =
+ (((h10P->pixmap_width + 15) / 16) * 16 - h10P->pixmap_width) * 8;
+ *bits_per_itemP = 16;
+@@ -635,6 +639,7 @@ processX11Header(X11WDFileHeader * const h11P,
+
+ *colsP = h11FixedP->pixmap_width;
+ *rowsP = h11FixedP->pixmap_height;
++ overflow2(h11FixedP->bytes_per_line, 8);
+ *padrightP =
+ h11FixedP->bytes_per_line * 8 -
+ h11FixedP->pixmap_width * h11FixedP->bits_per_pixel;
+diff --git a/converter/pbm/mdatopbm.c b/converter/pbm/mdatopbm.c
+index 461b3f8..c8bab6c 100644
+--- a/converter/pbm/mdatopbm.c
++++ b/converter/pbm/mdatopbm.c
+@@ -245,10 +245,13 @@ main(int argc, char **argv) {
+ pm_readlittleshort(infile, &yy); nInCols = yy;
+ }
+
++ overflow2(nOutCols, 8);
+ nOutCols = 8 * nInCols;
+ nOutRows = nInRows;
+- if (bScale)
++ if (bScale) {
++ overflow2(nOutRows, 2);
+ nOutRows *= 2;
++ }
+
+ data = pbm_allocarray(nOutCols, nOutRows);
+
+diff --git a/converter/pbm/mgrtopbm.c b/converter/pbm/mgrtopbm.c
+index 9f7004a..f2c1590 100644
+--- a/converter/pbm/mgrtopbm.c
++++ b/converter/pbm/mgrtopbm.c
+@@ -67,6 +67,7 @@ readMgrHeader(FILE * const ifP,
+
+ *colsP = (((int)head.h_wide - ' ') << 6) + ((int)head.l_wide - ' ');
+ *rowsP = (((int)head.h_high - ' ') << 6) + ((int) head.l_high - ' ');
++ overflow_add(*colsP, pad);
+ *padrightP = ( ( *colsP + pad - 1 ) / pad ) * pad - *colsP;
+ }
+
+diff --git a/converter/pbm/pbmto4425.c b/converter/pbm/pbmto4425.c
+index 1d97ac6..c4c8cbb 100644
+--- a/converter/pbm/pbmto4425.c
++++ b/converter/pbm/pbmto4425.c
+@@ -2,6 +2,7 @@
+
+ #include "nstring.h"
+ #include "pbm.h"
++#include
+
+ static char bit_table[2][3] = {
+ {1, 4, 0x10},
+@@ -160,7 +161,7 @@ main(int argc, char * argv[]) {
+ xres = vmap_width * 2;
+ yres = vmap_height * 3;
+
+- vmap = malloc(vmap_width * vmap_height * sizeof(char));
++ vmap = malloc3(vmap_width, vmap_height, sizeof(char));
+ if(vmap == NULL)
+ {
+ pm_error( "Cannot allocate memory" );
+diff --git a/converter/pbm/pbmtogem.c b/converter/pbm/pbmtogem.c
+index 4fd30e9..c82757d 100644
+--- a/converter/pbm/pbmtogem.c
++++ b/converter/pbm/pbmtogem.c
+@@ -79,6 +79,7 @@ putinit (int const rows, int const cols)
+ bitsperitem = 0;
+ bitshift = 7;
+ outcol = 0;
++ overflow_add(cols, 7);
+ outmax = (cols + 7) / 8;
+ outrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char));
+ lastrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char));
+diff --git a/converter/pbm/pbmtogo.c b/converter/pbm/pbmtogo.c
+index 4f84f39..943dc84 100644
+--- a/converter/pbm/pbmtogo.c
++++ b/converter/pbm/pbmtogo.c
+@@ -158,6 +158,7 @@ main(int argc,
+ bitrow = pbm_allocrow(cols);
+
+ /* Round cols up to the nearest multiple of 8. */
++ overflow_add(cols, 7);
+ rucols = ( cols + 7 ) / 8;
+ bytesperrow = rucols; /* GraphOn uses bytes */
+ rucols = rucols * 8;
+diff --git a/converter/pbm/pbmtolj.c b/converter/pbm/pbmtolj.c
+index 3cd7670..0b51932 100644
+--- a/converter/pbm/pbmtolj.c
++++ b/converter/pbm/pbmtolj.c
+@@ -120,7 +120,11 @@ parseCommandLine(int argc, char ** argv,
+ static void
+ allocateBuffers(unsigned int const cols) {
+
++ overflow_add(cols, 8);
+ rowBufferSize = (cols + 7) / 8;
++ overflow_add(rowBufferSize, 128);
++ overflow_add(rowBufferSize, rowBufferSize+128);
++ overflow_add(rowBufferSize+10, rowBufferSize/8);
+ packBufferSize = rowBufferSize + (rowBufferSize + 127) / 128 + 1;
+ deltaBufferSize = rowBufferSize + rowBufferSize / 8 + 10;
+
+diff --git a/converter/pbm/pbmtomda.c b/converter/pbm/pbmtomda.c
+index 3ad5149..9efe5cf 100644
+--- a/converter/pbm/pbmtomda.c
++++ b/converter/pbm/pbmtomda.c
+@@ -179,6 +179,7 @@ int main(int argc, char **argv)
+
+ nOutRowsUnrounded = bScale ? nInRows/2 : nInRows;
+
++ overflow_add(nOutRowsUnrounded, 3);
+ nOutRows = ((nOutRowsUnrounded + 3) / 4) * 4;
+ /* MDA wants rows a multiple of 4 */
+ nOutCols = nInCols / 8;
+diff --git a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c
+index ae36e0d..b8c89c9 100644
+--- a/converter/pbm/pbmtoppa/pbm.c
++++ b/converter/pbm/pbmtoppa/pbm.c
+@@ -154,6 +154,7 @@ pbm_readline(pbm_stat * const pbmStatP,
+ break;
+ case P4: {
+ int tmp, tmp2;
++ overflow_add(pbmStatP->width, 7);
+ tmp = (pbmStatP->width+7)/8;
+ tmp2 = fread(data,1,tmp,pbmStatP->fptr);
+ if (tmp2 == tmp) {
+@@ -186,6 +187,7 @@ pbm_unreadline(pbm_stat * const pbmStatP,
+
+ if (!pbmStatP->unread) {
+ pbmStatP->unread = 1;
++ overflow_add(pbmStatP->width, 7);
+ pbmStatP->revdata = malloc ((pbmStatP->width+7)/8);
+ memcpy(pbmStatP->revdata, data, (pbmStatP->width+7)/8);
+ --pbmStatP->current_line;
+diff --git a/converter/pbm/pbmtoppa/pbmtoppa.c b/converter/pbm/pbmtoppa/pbmtoppa.c
+index ff4a599..aa510ec 100644
+--- a/converter/pbm/pbmtoppa/pbmtoppa.c
++++ b/converter/pbm/pbmtoppa/pbmtoppa.c
+@@ -453,6 +453,7 @@ main(int argc, char *argv[]) {
+ pm_error("main(): unrecognized parameter '%s'", argv[argn]);
+ }
+
++ overflow_add(Width, 7);
+ Pwidth=(Width+7)/8;
+ printer.fptr=out;
+
+diff --git a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c
+index ecb72b3..600461f 100644
+--- a/converter/pbm/pbmtoxbm.c
++++ b/converter/pbm/pbmtoxbm.c
+@@ -352,6 +352,7 @@ convertRaster(FILE * const ifP,
+
+ unsigned char * bitrow;
+ unsigned int row;
++ overflow_add(cols, padright);
+
+ putinit(xbmVersion);
+
+diff --git a/converter/pbm/pktopbm.c b/converter/pbm/pktopbm.c
+index 712f339..b6fcb02 100644
+--- a/converter/pbm/pktopbm.c
++++ b/converter/pbm/pktopbm.c
+@@ -280,6 +280,7 @@ main(int argc, char *argv[]) {
+ if (flagbyte == 7) { /* long form preamble */
+ integer packetlength = get32() ; /* character packet length */
+ car = get32() ; /* character number */
++ overflow_add(packetlength, pktopbm_pkloc);
+ endofpacket = packetlength + pktopbm_pkloc;
+ /* calculate end of packet */
+ if ((car >= MAXPKCHAR) || !filename[car]) {
+diff --git a/converter/pbm/thinkjettopbm.l b/converter/pbm/thinkjettopbm.l
+index 5de4f2b..cc1810c 100644
+--- a/converter/pbm/thinkjettopbm.l
++++ b/converter/pbm/thinkjettopbm.l
+@@ -114,7 +114,9 @@ DIG [0-9]
+ \033\*b{DIG}+W {
+ int l;
+ if (rowCount >= rowCapacity) {
++ overflow_add(rowCapacity, 100);
+ rowCapacity += 100;
++ overflow2(rowCapacity, sizeof *rows);
+ rows = realloc (rows, rowCapacity * sizeof *rows);
+ if (rows == NULL)
+ pm_error ("Out of memory.");
+@@ -226,6 +228,7 @@ yywrap (void)
+ /*
+ * Quite simple since ThinkJet bit arrangement matches PBM
+ */
++ overflow2(maxRowLength, 8);
+ pbm_writepbminit(stdout, maxRowLength*8, rowCount, 0);
+
+ packed_bitrow = malloc(maxRowLength);
+diff --git a/converter/pbm/ybmtopbm.c b/converter/pbm/ybmtopbm.c
+index 2a42908..cf1ff03 100644
+--- a/converter/pbm/ybmtopbm.c
++++ b/converter/pbm/ybmtopbm.c
+@@ -43,6 +43,7 @@ getinit(FILE * const ifP,
+ pm_error("EOF / read error");
+
+ *depthP = 1;
++ overflow_add(*colsP, 15);
+ }
+
+
+diff --git a/converter/pgm/lispmtopgm.c b/converter/pgm/lispmtopgm.c
+index 40dd3fb..8dd9cae 100644
+--- a/converter/pgm/lispmtopgm.c
++++ b/converter/pgm/lispmtopgm.c
+@@ -58,6 +58,7 @@ main( argc, argv )
+ pm_error( "depth (%d bits) is too large", depth);
+
+ pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 );
++ overflow_add(cols, 7);
+ grayrow = pgm_allocrow( ( cols + 7 ) / 8 * 8 );
+
+ for ( row = 0; row < rows; ++row )
+@@ -103,6 +104,7 @@ getinit( file, colsP, rowsP, depthP, padrightP )
+ if ( *depthP == 0 )
+ *depthP = 1; /* very old file */
+
++ overflow_add((int)colsP, 31);
+ *padrightP = ( ( *colsP + 31 ) / 32 ) * 32 - *colsP;
+
+ if ( *colsP != (cols_32 - *padrightP) ) {
+diff --git a/converter/pgm/psidtopgm.c b/converter/pgm/psidtopgm.c
+index 07417d1..25bb311 100644
+--- a/converter/pgm/psidtopgm.c
++++ b/converter/pgm/psidtopgm.c
+@@ -78,6 +78,7 @@ main(int argc,
+ pm_error("bits/sample (%d) is too large.", bitspersample);
+
+ pgm_writepgminit(stdout, cols, rows, maxval, 0);
++ overflow_add(cols, 7);
+ grayrow = pgm_allocrow((cols + 7) / 8 * 8);
+ for (row = 0; row < rows; ++row) {
+ unsigned int col;
+diff --git a/converter/ppm/Makefile b/converter/ppm/Makefile
+index 003ef8d..b97349d 100644
+--- a/converter/ppm/Makefile
++++ b/converter/ppm/Makefile
+@@ -11,7 +11,7 @@ SUBDIRS = hpcdtoppm ppmtompeg
+
+ PORTBINARIES = 411toppm eyuvtoppm gouldtoppm ilbmtoppm imgtoppm \
+ leaftoppm mtvtoppm neotoppm \
+- pcxtoppm pc1toppm pi1toppm picttoppm pjtoppm \
++ pcxtoppm pc1toppm pi1toppm pjtoppm \
+ ppmtoacad ppmtoapplevol ppmtoarbtxt ppmtoascii \
+ ppmtobmp ppmtoeyuv ppmtogif ppmtoicr ppmtoilbm \
+ ppmtoleaf ppmtolj ppmtomitsu ppmtoneo \
+diff --git a/converter/ppm/ilbmtoppm.c b/converter/ppm/ilbmtoppm.c
+index b9b8986..f4fe331 100644
+--- a/converter/ppm/ilbmtoppm.c
++++ b/converter/ppm/ilbmtoppm.c
+@@ -608,6 +608,7 @@ decode_row(FILE * const ifP,
+ rawtype *chp;
+
+ cols = bmhdP->w;
++ overflow_add(cols, 15);
+ bytes = RowBytes(cols);
+ for( plane = 0; plane < nPlanes; plane++ ) {
+ int mask;
+@@ -695,6 +696,23 @@ decode_mask(FILE * const ifP,
+ Multipalette handling
+ ****************************************************************************/
+
++static void *
++xmalloc2(x, y)
++ int x;
++ int y;
++{
++ void *mem;
++
++ overflow2(x,y);
++ if( x * y == 0 )
++ return NULL;
++
++ mem = malloc2(x,y);
++ if( mem == NULL )
++ pm_error("out of memory allocating %d bytes", x * y);
++ return mem;
++}
++
+
+ static void
+ multi_adjust(ColorMap * const cmapP,
+@@ -1363,6 +1381,9 @@ dcol_to_ppm(FILE * const ifP,
+ if( redmaxval != maxval || greenmaxval != maxval || bluemaxval != maxval )
+ pm_message("scaling colors to %d bits", pm_maxvaltobits(maxval));
+
++ overflow_add(redmaxval, 1);
++ overflow_add(greenmaxval, 1);
++ overflow_add(bluemaxval, 1);
+ MALLOCARRAY_NOFAIL(redtable, redmaxval +1);
+ MALLOCARRAY_NOFAIL(greentable, greenmaxval +1);
+ MALLOCARRAY_NOFAIL(bluetable, bluemaxval +1);
+@@ -1802,7 +1823,9 @@ PCHG_ConvertSmall(PCHGHeader * const pchgP,
+ ChangeCount32 = *data++;
+ remDataSize -= 2;
+
++ overflow_add(ChangeCount16, ChangeCount32);
+ changes = ChangeCount16 + ChangeCount32;
++ overflow_add(changes, 1);
+ for (i = 0; i < changes; ++i) {
+ if (totalchanges >= pchgP->TotalChanges) goto fail;
+ if (remDataSize < 2) goto fail;
+@@ -2067,6 +2090,9 @@ read_pchg(FILE * const ifP,
+ cmap->mp_change[i] = NULL;
+ if( PCHG.StartLine < 0 ) {
+ int nch;
++ if(PCHG.MaxReg < PCHG.MinReg)
++ pm_error("assert: MinReg > MaxReg");
++ overflow_add(PCHG.MaxReg-PCHG.MinReg, 2);
+ nch = PCHG.MaxReg - PCHG.MinReg +1;
+ MALLOCARRAY_NOFAIL(cmap->mp_init, nch + 1);
+ for( i = 0; i < nch; i++ )
+@@ -2143,6 +2169,7 @@ process_body( FILE * const ifP,
+ if (typeid == ID_ILBM) {
+ int isdeep;
+
++ overflow_add(bmhdP->w, 15);
+ MALLOCARRAY_NOFAIL(ilbmrow, RowBytes(bmhdP->w));
+ *viewportmodesP |= fakeviewport; /* -isham/-isehb */
+
+diff --git a/converter/ppm/imgtoppm.c b/converter/ppm/imgtoppm.c
+index 7078b88..eb8509e 100644
+--- a/converter/ppm/imgtoppm.c
++++ b/converter/ppm/imgtoppm.c
+@@ -84,6 +84,7 @@ main(int argc, char ** argv) {
+ len = atoi((char*) buf );
+ if ( fread( buf, len, 1, ifp ) != 1 )
+ pm_error( "bad colormap buf" );
++ overflow2(cmaplen, 3);
+ if ( cmaplen * 3 != len )
+ {
+ pm_message(
+@@ -105,6 +106,7 @@ main(int argc, char ** argv) {
+ pm_error( "bad pixel data header" );
+ buf[8] = '\0';
+ len = atoi((char*) buf );
++ overflow2(cols, rows);
+ if ( len != cols * rows )
+ pm_message(
+ "pixel data length (%d) does not match image size (%d)",
+diff --git a/converter/ppm/pcxtoppm.c b/converter/ppm/pcxtoppm.c
+index e252ba2..270ae3b 100644
+--- a/converter/ppm/pcxtoppm.c
++++ b/converter/ppm/pcxtoppm.c
+@@ -409,6 +409,7 @@ pcx_planes_to_pixels(pixels, bitplanes, bytesperline, planes, bitsperpixel)
+ /*
+ * clear the pixel buffer
+ */
++ overflow2(bytesperline, 8);
+ npixels = (bytesperline * 8) / bitsperpixel;
+ p = pixels;
+ while (--npixels >= 0)
+@@ -470,6 +471,7 @@ pcx_16col_to_ppm(FILE * const ifP,
+ }
+
+ /* BytesPerLine should be >= BitsPerPixel * cols / 8 */
++ overflow2(BytesPerLine, 8);
+ rawcols = BytesPerLine * 8 / BitsPerPixel;
+ if (headerCols > rawcols) {
+ pm_message("warning - BytesPerLine = %d, "
+diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c
+index 9cf570e..6020f67 100644
+--- a/converter/ppm/picttoppm.c
++++ b/converter/ppm/picttoppm.c
+@@ -1,3 +1,4 @@
++#error "Unfixable. Don't ship me"
+ /*
+ * picttoppm.c -- convert a MacIntosh PICT file to PPM format.
+ *
+diff --git a/converter/ppm/pjtoppm.c b/converter/ppm/pjtoppm.c
+index ffb01d0..eb11e8d 100644
+--- a/converter/ppm/pjtoppm.c
++++ b/converter/ppm/pjtoppm.c
+@@ -149,12 +149,17 @@ main(int argc, const char ** argv) {
+ case 'V': /* send plane */
+ case 'W': /* send last plane */
+ if (rows == -1 || row >= rows || image == NULL) {
+- if (rows == -1 || row >= rows)
++ if (rows == -1 || row >= rows) {
++ overflow_add(rows, 100);
+ rows += 100;
++ }
++
+ if (image == NULL) {
++ overflow2(rows,planes);
+ MALLOCARRAY(image, uintProduct(rows, planes));
+ MALLOCARRAY(imlen, uintProduct(rows, planes));
+ } else {
++ overflow2(rows,planes);
+ REALLOCARRAY(image, uintProduct(rows, planes));
+ REALLOCARRAY(imlen, uintProduct(rows, planes));
+ }
+@@ -235,8 +240,10 @@ main(int argc, const char ** argv) {
+ col += 2)
+ for (cmd = image[plane + row * planes][col],
+ val = image[plane + row * planes][col+1];
+- cmd >= 0 && i < newcols; cmd--, i++)
++ cmd >= 0 && i < newcols; cmd--, i++) {
+ buf[i] = val;
++ overflow_add(i, 1);
++ }
+ cols = MAX(cols, i);
+ free(image[plane + row * planes]);
+ /*
+@@ -247,6 +254,7 @@ main(int argc, const char ** argv) {
+ image[plane + row * planes] = realloc(buf, i);
+ }
+ }
++ overflow2(cols, 8);
+ cols *= 8;
+ }
+
+diff --git a/converter/ppm/ppmtoeyuv.c b/converter/ppm/ppmtoeyuv.c
+index f5ce115..6f072be 100644
+--- a/converter/ppm/ppmtoeyuv.c
++++ b/converter/ppm/ppmtoeyuv.c
+@@ -114,6 +114,7 @@ create_multiplication_tables(const pixval maxval) {
+
+ int index;
+
++ overflow_add(maxval, 1);
+ MALLOCARRAY_NOFAIL(mult299 , maxval+1);
+ MALLOCARRAY_NOFAIL(mult587 , maxval+1);
+ MALLOCARRAY_NOFAIL(mult114 , maxval+1);
+diff --git a/converter/ppm/ppmtolj.c b/converter/ppm/ppmtolj.c
+index 7ed814e..b4e7db1 100644
+--- a/converter/ppm/ppmtolj.c
++++ b/converter/ppm/ppmtolj.c
+@@ -182,6 +182,7 @@ int main(int argc, char *argv[]) {
+ ppm_readppminit( ifp, &cols, &rows, &maxval, &format );
+ pixelrow = ppm_allocrow( cols );
+
++ overflow2(cols, 6);
+ obuf = (unsigned char *) pm_allocrow(cols * 3, sizeof(unsigned char));
+ cbuf = (unsigned char *) pm_allocrow(cols * 6, sizeof(unsigned char));
+ if (mode == C_TRANS_MODE_DELTA)
+diff --git a/converter/ppm/ppmtomitsu.c b/converter/ppm/ppmtomitsu.c
+index 50b790d..63d3182 100644
+--- a/converter/ppm/ppmtomitsu.c
++++ b/converter/ppm/ppmtomitsu.c
+@@ -685,6 +685,8 @@ main(int argc, char * argv[]) {
+ medias = MSize_User;
+
+ if (dpi300) {
++ overflow2(medias.maxcols, 2);
++ overflow2(medias.maxrows, 2);
+ medias.maxcols *= 2;
+ medias.maxrows *= 2;
+ }
+diff --git a/converter/ppm/ppmtopcx.c b/converter/ppm/ppmtopcx.c
+index 76f0629..e7b06ff 100644
+--- a/converter/ppm/ppmtopcx.c
++++ b/converter/ppm/ppmtopcx.c
+@@ -422,6 +422,8 @@ ppmTo16ColorPcx(pixel ** const pixels,
+ else Planes = 1;
+ }
+ }
++ overflow2(BitsPerPixel, cols);
++ overflow_add(BitsPerPixel * cols, 7);
+ BytesPerLine = ((cols * BitsPerPixel) + 7) / 8;
+ MALLOCARRAY_NOFAIL(indexRow, cols);
+ MALLOCARRAY_NOFAIL(planesrow, BytesPerLine);
+diff --git a/converter/ppm/ppmtopict.c b/converter/ppm/ppmtopict.c
+index 36464b6..c91ccf2 100644
+--- a/converter/ppm/ppmtopict.c
++++ b/converter/ppm/ppmtopict.c
+@@ -450,6 +450,8 @@ main(int argc, const char ** argv) {
+ putShort(stdout, 0); /* mode */
+
+ /* Finally, write out the data. */
++ overflow_add(cols/MAX_COUNT, 1);
++ overflow_add(cols, cols/MAX_COUNT+1);
+ outBuf = malloc((unsigned)(cols+cols/MAX_COUNT+1));
+ for (row = 0, oc = 0; row < rows; ++row) {
+ unsigned int rowSize;
+diff --git a/converter/ppm/ppmtopj.c b/converter/ppm/ppmtopj.c
+index d116773..49d08fc 100644
+--- a/converter/ppm/ppmtopj.c
++++ b/converter/ppm/ppmtopj.c
+@@ -179,6 +179,7 @@ char *argv[];
+ pixels = ppm_readppm( ifp, &cols, &rows, &maxval );
+
+ pm_close( ifp );
++ overflow2(cols,2);
+ obuf = (unsigned char *) pm_allocrow(cols, sizeof(unsigned char));
+ cbuf = (unsigned char *) pm_allocrow(cols * 2, sizeof(unsigned char));
+
+diff --git a/converter/ppm/ppmtopjxl.c b/converter/ppm/ppmtopjxl.c
+index 90bcef0..72d0027 100644
+--- a/converter/ppm/ppmtopjxl.c
++++ b/converter/ppm/ppmtopjxl.c
+@@ -267,6 +267,9 @@ main(int argc, const char * argv[]) {
+ if (maxval > PCL_MAXVAL)
+ pm_error("color range too large; reduce with ppmcscale");
+
++ if (cols < 0 || rows < 0)
++ pm_error("negative size is not possible");
++
+ /* Figure out the colormap. */
+ pm_message("Computing colormap...");
+ chv = ppm_computecolorhist(pixels, cols, rows, MAXCOLORS, &colors);
+@@ -286,6 +289,8 @@ main(int argc, const char * argv[]) {
+ case 0: /* direct mode (no palette) */
+ bpp = bitsperpixel(maxval); /* bits per pixel */
+ bpg = bpp; bpb = bpp;
++ overflow2(bpp, 3);
++ overflow_add(bpp*3, 7);
+ bpp = (bpp*3+7)>>3; /* bytes per pixel now */
+ bpr = (bpp<<3)-bpg-bpb;
+ bpp *= cols; /* bytes per row now */
+@@ -295,9 +300,13 @@ main(int argc, const char * argv[]) {
+ case 3: case 7: pclindex++;
+ default:
+ bpp = 8/pclindex;
++ overflow_add(cols, bpp);
++ if(bpp == 0)
++ pm_error("assert: no bpp");
+ bpp = (cols+bpp-1)/bpp; /* bytes per row */
+ }
+ }
++ overflow2(bpp,2);
+ inrow = (char *)malloc((unsigned)bpp);
+ outrow = (char *)malloc((unsigned)bpp*2);
+ runcnt = (signed char *)malloc((unsigned)bpp);
+diff --git a/converter/ppm/ppmtowinicon.c b/converter/ppm/ppmtowinicon.c
+index c673798..f026c08 100644
+--- a/converter/ppm/ppmtowinicon.c
++++ b/converter/ppm/ppmtowinicon.c
+@@ -12,6 +12,7 @@
+
+ #include
+ #include
++#include
+
+ #include "pm_c_util.h"
+ #include "winico.h"
+@@ -214,6 +215,7 @@ createAndBitmap (gray ** const ba, int const cols, int const rows,
+ MALLOCARRAY_NOFAIL(rowData, rows);
+ icBitmap->xBytes = xBytes;
+ icBitmap->data = rowData;
++ overflow2(xBytes, rows);
+ icBitmap->size = xBytes * rows;
+ for (y=0;yxBytes = xBytes;
+ icBitmap->data = rowData;
++ overflow2(xBytes, rows);
+ icBitmap->size = xBytes * rows;
+
+ for (y=0;yxBytes = xBytes;
+ icBitmap->data = rowData;
++ overflow2(xBytes, rows);
+ icBitmap->size = xBytes * rows;
+
+ for (y=0;ybitcount = bpp;
+ entry->ih = createInfoHeader(entry, xorBitmap, andBitmap);
+ entry->colors = palette->colors;
++ overflow2(4, entry->color_count);
++ overflow_add(xorBitmap->size, andBitmap->size);
++ overflow_add(xorBitmap->size + andBitmap->size, 40);
++ overflow_add(xorBitmap->size + andBitmap->size + 40, 4 * entry->color_count);
+ entry->size_in_bytes =
+ xorBitmap->size + andBitmap->size + 40 + (4 * entry->color_count);
+ if (verbose)
+diff --git a/converter/ppm/ppmtoxpm.c b/converter/ppm/ppmtoxpm.c
+index 0e31692..1b3923f 100644
+--- a/converter/ppm/ppmtoxpm.c
++++ b/converter/ppm/ppmtoxpm.c
+@@ -198,6 +198,7 @@ genNumstr(unsigned int const input, int const digits) {
+ unsigned int i;
+
+ /* Allocate memory for printed number. Abort if error. */
++ overflow_add(digits, 1);
+ if (!(str = (char *) malloc(digits + 1)))
+ pm_error("out of memory");
+
+@@ -315,6 +316,7 @@ genCmap(colorhist_vector const chv,
+ unsigned int charsPerPixel;
+ unsigned int xpmMaxval;
+
++ if (includeTransparent) overflow_add(ncolors, 1);
+ MALLOCARRAY(cmap, cmapSize);
+ if (cmapP == NULL)
+ pm_error("Out of memory allocating %u bytes for a color map.",
+diff --git a/converter/ppm/qrttoppm.c b/converter/ppm/qrttoppm.c
+index 935463e..653084c 100644
+--- a/converter/ppm/qrttoppm.c
++++ b/converter/ppm/qrttoppm.c
+@@ -46,7 +46,7 @@ main( argc, argv )
+
+ ppm_writeppminit( stdout, cols, rows, maxval, 0 );
+ pixelrow = ppm_allocrow( cols );
+- buf = (unsigned char *) malloc( 3 * cols );
++ buf = (unsigned char *) malloc2( 3 , cols );
+ if ( buf == (unsigned char *) 0 )
+ pm_error( "out of memory" );
+
+diff --git a/converter/ppm/sldtoppm.c b/converter/ppm/sldtoppm.c
+index 2fef023..ce73025 100644
+--- a/converter/ppm/sldtoppm.c
++++ b/converter/ppm/sldtoppm.c
+@@ -506,6 +506,8 @@ slider(slvecfn slvec,
+
+ /* Allocate image buffer and clear it to black. */
+
++ overflow_add(ixdots, 1);
++ overflow_add(iydots, 1);
+ pixels = ppm_allocarray(pixcols = ixdots + 1, pixrows = iydots + 1);
+ PPM_ASSIGN(rgbcolor, 0, 0, 0);
+ ppmd_filledrectangle(pixels, pixcols, pixrows, pixmaxval, 0, 0,
+diff --git a/converter/ppm/ximtoppm.c b/converter/ppm/ximtoppm.c
+index 9620942..e9083f3 100644
+--- a/converter/ppm/ximtoppm.c
++++ b/converter/ppm/ximtoppm.c
+@@ -118,6 +118,7 @@ ReadXimHeader(FILE * const in_fp,
+ header->bits_channel = atoi(a_head.bits_per_channel);
+ header->alpha_flag = atoi(a_head.alpha_channel);
+ if (strlen(a_head.author)) {
++ overflow_add(strlen(a_head.author),1);
+ if (!(header->author = calloc((unsigned int)strlen(a_head.author)+1,
+ 1))) {
+ pm_message("ReadXimHeader: can't calloc author string" );
+@@ -127,6 +128,7 @@ ReadXimHeader(FILE * const in_fp,
+ strncpy(header->author, a_head.author, strlen(a_head.author));
+ }
+ if (strlen(a_head.date)) {
++ overflow_add(strlen(a_head.date),1);
+ if (!(header->date =calloc((unsigned int)strlen(a_head.date)+1,1))){
+ pm_message("ReadXimHeader: can't calloc date string" );
+ return(0);
+@@ -135,6 +137,7 @@ ReadXimHeader(FILE * const in_fp,
+ strncpy(header->date, a_head.date, strlen(a_head.date));
+ }
+ if (strlen(a_head.program)) {
++ overflow_add(strlen(a_head.program),1);
+ if (!(header->program = calloc(
+ (unsigned int)strlen(a_head.program) + 1, 1))) {
+ pm_message("ReadXimHeader: can't calloc program string" );
+@@ -161,6 +164,7 @@ ReadXimHeader(FILE * const in_fp,
+ if (header->nchannels == 3 && header->bits_channel == 8)
+ header->ncolors = 0;
+ else if (header->nchannels == 1 && header->bits_channel == 8) {
++ overflow2(header->ncolors, sizeof(Color));
+ header->colors = (Color *)calloc((unsigned int)header->ncolors,
+ sizeof(Color));
+ if (header->colors == NULL) {
+diff --git a/editor/pamcut.c b/editor/pamcut.c
+index 1fc9d9b..ad0e030 100644
+--- a/editor/pamcut.c
++++ b/editor/pamcut.c
+@@ -799,6 +799,8 @@ cutOneImage(FILE * const ifP,
+
+ outpam = inpam; /* Initial value -- most fields should be same */
+ outpam.file = ofP;
++ overflow_add(rightcol, 1);
++ overflow_add(bottomrow, 1);
+ outpam.width = rightcol - leftcol + 1;
+ outpam.height = bottomrow - toprow + 1;
+
+diff --git a/editor/pnmgamma.c b/editor/pnmgamma.c
+index 1fdf20e..98b7e90 100644
+--- a/editor/pnmgamma.c
++++ b/editor/pnmgamma.c
+@@ -596,6 +596,7 @@ createGammaTables(enum transferFunction const transferFunction,
+ xelval ** const btableP) {
+
+ /* Allocate space for the tables. */
++ overflow_add(maxval, 1);
+ MALLOCARRAY(*rtableP, maxval+1);
+ MALLOCARRAY(*gtableP, maxval+1);
+ MALLOCARRAY(*btableP, maxval+1);
+diff --git a/editor/pnmhisteq.c b/editor/pnmhisteq.c
+index a339f73..c2c85a3 100644
+--- a/editor/pnmhisteq.c
++++ b/editor/pnmhisteq.c
+@@ -107,6 +107,7 @@ computeLuminosityHistogram(xel * const * const xels,
+ unsigned int pixelCount;
+ unsigned int * lumahist;
+
++ overflow_add(maxval, 1);
+ MALLOCARRAY(lumahist, maxval + 1);
+ if (lumahist == NULL)
+ pm_error("Out of storage allocating array for %u histogram elements",
+diff --git a/editor/pnmindex.csh b/editor/pnmindex.csh
+index c6f1e84..c513a84 100755
+--- a/editor/pnmindex.csh
++++ b/editor/pnmindex.csh
+@@ -1,5 +1,7 @@
+ #!/bin/csh -f
+ #
++echo "Unsafe code, needs debugging, do not ship"
++exit 1
+ # pnmindex - build a visual index of a bunch of anymaps
+ #
+ # Copyright (C) 1991 by Jef Poskanzer.
+diff --git a/editor/pnmpad.c b/editor/pnmpad.c
+index 55cdcd6..10da3af 100644
+--- a/editor/pnmpad.c
++++ b/editor/pnmpad.c
+@@ -654,6 +654,8 @@ main(int argc, const char ** argv) {
+
+ computePadSizes(cmdline, cols, rows, &lpad, &rpad, &tpad, &bpad);
+
++ overflow_add(cols, lpad);
++ overflow_add(cols + lpad, rpad);
+ newcols = cols + lpad + rpad;
+
+ if (cmdline.reportonly)
+diff --git a/editor/pnmremap.c b/editor/pnmremap.c
+index 0c0096b..8b86cb7 100644
+--- a/editor/pnmremap.c
++++ b/editor/pnmremap.c
+@@ -468,6 +468,7 @@ fserr_init(struct pam * const pamP,
+
+ unsigned int const fserrSize = pamP->width + 2;
+
++ overflow_add(pamP->width, 2);
+ fserrP->width = pamP->width;
+
+ MALLOCARRAY(fserrP->thiserr, pamP->depth);
+@@ -506,6 +507,7 @@ floydInitRow(struct pam * const pamP,
+
+ unsigned int col;
+
++ overflow_add(pamP->width, 2);
+ for (col = 0; col < pamP->width + 2; ++col) {
+ unsigned int plane;
+ for (plane = 0; plane < pamP->depth; ++plane)
+diff --git a/editor/pnmscalefixed.c b/editor/pnmscalefixed.c
+index 884ca31..f4d7086 100644
+--- a/editor/pnmscalefixed.c
++++ b/editor/pnmscalefixed.c
+@@ -214,6 +214,7 @@ compute_output_dimensions(const struct cmdline_info cmdline,
+ const int rows, const int cols,
+ int * newrowsP, int * newcolsP) {
+
++ overflow2(rows, cols);
+ if (cmdline.pixels) {
+ if (rows * cols <= cmdline.pixels) {
+ *newrowsP = rows;
+@@ -265,6 +266,7 @@ compute_output_dimensions(const struct cmdline_info cmdline,
+
+ if (*newcolsP < 1) *newcolsP = 1;
+ if (*newrowsP < 1) *newrowsP = 1;
++ overflow2(*newcolsP, *newrowsP);
+ }
+
+
+@@ -446,6 +448,8 @@ main(int argc, char **argv ) {
+ unfilled. We can address that by stretching, whereas the other
+ case would require throwing away some of the input.
+ */
++ overflow2(newcols, SCALE);
++ overflow2(newrows, SCALE);
+ sxscale = SCALE * newcols / cols;
+ syscale = SCALE * newrows / rows;
+
+diff --git a/editor/ppmdither.c b/editor/ppmdither.c
+index ec1b977..c46a974 100644
+--- a/editor/ppmdither.c
++++ b/editor/ppmdither.c
+@@ -352,6 +352,9 @@ dithMatrix(unsigned int const dithPower) {
+ assert(dithPower < sizeof(unsigned int) * 8);
+
+ {
++ overflow2(dithDim, sizeof(*dithMat));
++ overflow3(dithDim, dithDim, sizeof(**dithMat));
++ overflow_add(dithDim * sizeof(*dithMat), dithDim * dithDim * sizeof(**dithMat));
+ unsigned int const dithMatSize =
+ (dithDim * sizeof(*dithMat)) + /* pointers */
+ (dithDim * dithDim * sizeof(**dithMat)); /* data */
+diff --git a/editor/specialty/pamoil.c b/editor/specialty/pamoil.c
+index 6cb8d3a..6f4bde9 100644
+--- a/editor/specialty/pamoil.c
++++ b/editor/specialty/pamoil.c
+@@ -112,6 +112,7 @@ main(int argc, char *argv[] ) {
+ tuples = pnm_readpam(ifp, &inpam, PAM_STRUCT_SIZE(tuple_type));
+ pm_close(ifp);
+
++ overflow_add(inpam.maxval, 1);
+ MALLOCARRAY(hist, inpam.maxval + 1);
+ if (hist == NULL)
+ pm_error("Unable to allocate memory for histogram.");
+diff --git a/lib/libpam.c b/lib/libpam.c
+index a8f140b..e6986f1 100644
+--- a/lib/libpam.c
++++ b/lib/libpam.c
+@@ -225,7 +225,8 @@ allocPamRow(const struct pam * const pamP) {
+ unsigned int const bytesPerTuple = allocationDepth(pamP) * sizeof(sample);
+ tuple * tuplerow;
+
+- tuplerow = malloc(pamP->width * (sizeof(tuple *) + bytesPerTuple));
++ overflow_add(sizeof(tuple *), bytesPerTuple);
++ tuplerow = malloc2(pamP->width, (sizeof(tuple *) + bytesPerTuple));
+
+ if (tuplerow != NULL) {
+ /* Now we initialize the pointers to the individual tuples
+diff --git a/lib/libpammap.c b/lib/libpammap.c
+index 569156f..bc24d22 100644
+--- a/lib/libpammap.c
++++ b/lib/libpammap.c
+@@ -108,6 +108,8 @@ allocTupleIntListItem(struct pam * const pamP) {
+ */
+ struct tupleint_list_item * retval;
+
++ overflow2(pamP->depth, sizeof(sample));
++ overflow_add(sizeof(*retval)-sizeof(retval->tupleint.tuple), pamP->depth*sizeof(sample));
+ unsigned int const size =
+ sizeof(*retval) - sizeof(retval->tupleint.tuple)
+ + pamP->depth * sizeof(sample);
+diff --git a/lib/libpm.c b/lib/libpm.c
+index 47a2f49..a263598 100644
+--- a/lib/libpm.c
++++ b/lib/libpm.c
+@@ -888,5 +888,53 @@ pm_parse_height(const char * const arg) {
+ return height;
+ }
+
++/*
++ * Maths wrapping
++ */
+
++void __overflow2(int a, int b)
++{
++ if(a < 0 || b < 0)
++ pm_error("object too large");
++ if(b == 0)
++ return;
++ if(a > INT_MAX / b)
++ pm_error("object too large");
++}
++
++void overflow3(int a, int b, int c)
++{
++ overflow2(a,b);
++ overflow2(a*b, c);
++}
++
++void overflow_add(int a, int b)
++{
++ if( a > INT_MAX - b)
++ pm_error("object too large");
++}
++
++void *malloc2(int a, int b)
++{
++ overflow2(a, b);
++ if(a*b == 0)
++ pm_error("Zero byte allocation");
++ return malloc(a*b);
++}
++
++void *malloc3(int a, int b, int c)
++{
++ overflow3(a, b, c);
++ if(a*b*c == 0)
++ pm_error("Zero byte allocation");
++ return malloc(a*b*c);
++}
++
++void *realloc2(void * a, int b, int c)
++{
++ overflow2(b, c);
++ if(b*c == 0)
++ pm_error("Zero byte allocation");
++ return realloc(a, b*c);
++}
+
+diff --git a/lib/pm.h b/lib/pm.h
+index 3fc92fb..17a25f1 100644
+--- a/lib/pm.h
++++ b/lib/pm.h
+@@ -441,5 +441,12 @@ pm_parse_height(const char * const arg);
+ }
+ #endif
+
++#define overflow2(a,b) __overflow2(a,b)
++void __overflow2(int, int);
++void overflow3(int, int, int);
++void overflow_add(int, int);
++void *malloc2(int, int);
++void *malloc3(int, int, int);
++void *realloc2(void *, int, int);
+
+ #endif
+diff --git a/other/pnmcolormap.c b/other/pnmcolormap.c
+index 7da3122..dafa390 100644
+--- a/other/pnmcolormap.c
++++ b/other/pnmcolormap.c
+@@ -1002,6 +1002,7 @@ colormapToSquare(struct pam * const pamP,
+ pamP->width = intsqrt;
+ else
+ pamP->width = intsqrt + 1;
++ overflow_add(intsqrt, 1);
+ }
+ {
+ unsigned int const intQuotient = colormap.size / pamP->width;
+diff --git a/urt/Runput.c b/urt/Runput.c
+index 3bc562a..cb6e7c5 100644
+--- a/urt/Runput.c
++++ b/urt/Runput.c
+@@ -202,9 +202,11 @@ RunSetup(rle_hdr * the_hdr)
+ if ( the_hdr->background != 0 )
+ {
+ register int i;
+- register rle_pixel *background =
+- (rle_pixel *)malloc( (unsigned)(the_hdr->ncolors + 1) );
++ register rle_pixel *background;
+ register int *bg_color;
++
++ overflow_add(the_hdr->ncolors,1);
++ background = (rle_pixel *)malloc( (unsigned)(the_hdr->ncolors + 1) );
+ /*
+ * If even number of bg color bytes, put out one more to get to
+ * 16 bit boundary.
+@@ -224,7 +226,7 @@ RunSetup(rle_hdr * the_hdr)
+ /* Big-endian machines are harder */
+ register int i, nmap = (1 << the_hdr->cmaplen) *
+ the_hdr->ncmap;
+- register char *h_cmap = (char *)malloc( nmap * 2 );
++ register char *h_cmap = (char *)malloc2( nmap, 2 );
+ if ( h_cmap == NULL )
+ {
+ fprintf( stderr,
+diff --git a/urt/rle.h b/urt/rle.h
+index 0071774..6a905ba 100644
+--- a/urt/rle.h
++++ b/urt/rle.h
+@@ -152,6 +152,17 @@ rle_hdr /* End of typedef. */
+ */
+ extern rle_hdr rle_dflt_hdr;
+
++/*
++ * Provided by pm library
++ */
++
++extern void overflow_add(int, int);
++#define overflow2(a,b) __overflow2(a,b)
++extern void __overflow2(int, int);
++extern void overflow3(int, int, int);
++extern void *malloc2(int, int);
++extern void *malloc3(int, int, int);
++extern void *realloc2(void *, int, int);
+
+ /* Declare RLE library routines. */
+
+diff --git a/urt/rle_addhist.c b/urt/rle_addhist.c
+index b165175..e09ed94 100644
+--- a/urt/rle_addhist.c
++++ b/urt/rle_addhist.c
+@@ -70,13 +70,18 @@ rle_addhist(char * argv[],
+ return;
+
+ length = 0;
+- for (i = 0; argv[i]; ++i)
++ for (i = 0; argv[i]; ++i) {
++ overflow_add(length, strlen(argv[i]));
++ overflow_add(length+1, strlen(argv[i]));
+ length += strlen(argv[i]) +1; /* length of each arg plus space. */
++ }
+
+ time(&temp);
+ timedate = ctime(&temp);
+ length += strlen(timedate); /* length of date and time in ASCII. */
+-
++ overflow_add(strlen(padding), 4);
++ overflow_add(strlen(histoire), strlen(padding) + 4);
++ overflow_add(length, strlen(histoire) + strlen(padding) + 4);
+ length += strlen(padding) + 3 + strlen(histoire) + 1;
+ /* length of padding, "on " and length of history name plus "="*/
+ if (in_hdr) /* if we are interested in the old comments... */
+@@ -84,8 +89,10 @@ rle_addhist(char * argv[],
+ else
+ old = NULL;
+
+- if (old && *old)
++ if (old && *old) {
++ overflow_add(length, strlen(old));
+ length += strlen(old); /* add length if there. */
++ }
+
+ ++length; /*Cater for the null. */
+
+diff --git a/urt/rle_getrow.c b/urt/rle_getrow.c
+index ae220f5..39010ba 100644
+--- a/urt/rle_getrow.c
++++ b/urt/rle_getrow.c
+@@ -164,6 +164,7 @@ rle_get_setup(rle_hdr * const the_hdr) {
+ char * cp;
+
+ VAXSHORT(comlen, infile); /* get comment length */
++ overflow_add(comlen, 1);
+ evenlen = (comlen + 1) & ~1; /* make it even */
+ if (evenlen) {
+ MALLOCARRAY(comment_buf, evenlen);
+diff --git a/urt/rle_hdr.c b/urt/rle_hdr.c
+index 1edb7a3..c3dd60f 100644
+--- a/urt/rle_hdr.c
++++ b/urt/rle_hdr.c
+@@ -148,6 +148,7 @@ rle_hdr_cp(rle_hdr * const fromHdrP,
+ if (toHdrP->cmap) {
+ size_t const size =
+ toHdrP->ncmap * (1 << toHdrP->cmaplen) * sizeof(rle_map);
++ overflow3(toHdrP->ncmap, 1<cmaplen, sizeof(rle_map));
+ toHdrP->cmap = malloc(size);
+ if (!toHdrP->cmap)
+ pm_error("Failed to allocate memory for %u color maps "
+@@ -163,12 +164,16 @@ rle_hdr_cp(rle_hdr * const fromHdrP,
+ const char ** cp;
+
+ /* Count the comments. */
+- for (cp = toHdrP->comments, size = 0; *cp; ++cp)
++ for (cp = toHdrP->comments, size = 0; *cp; ++cp) {
++ overflow_add(size, 1);
+ ++size;
++ }
+
+ /* Check if there are really any comments. */
+ if (size > 0) {
++ overflow_add(size, 1);
+ ++size; /* Copy the NULL pointer, too. */
++ overflow2(size, sizeof(char *));
+ size *= sizeof(char *);
+ toHdrP->comments = malloc(size);
+ if (!toHdrP->comments)
+diff --git a/urt/rle_open_f.c b/urt/rle_open_f.c
+index 1aeb644..595b15c 100644
+--- a/urt/rle_open_f.c
++++ b/urt/rle_open_f.c
+@@ -163,65 +163,7 @@ dealWithSubprocess(const char * const file_name,
+ FILE ** const fpP,
+ bool * const noSubprocessP,
+ const char ** const errorP) {
+-
+-#ifdef NO_OPEN_PIPES
+ *noSubprocessP = TRUE;
+-#else
+- const char *cp;
+-
+- reapChildren(catchingChildrenP, pids);
+-
+- /* Real file, not stdin or stdout. If name ends in ".Z",
+- * pipe from/to un/compress (depending on r/w mode).
+- *
+- * If it starts with "|", popen that command.
+- */
+-
+- cp = file_name + strlen(file_name) - 2;
+- /* Pipe case. */
+- if (file_name[0] == '|') {
+- pid_t thepid; /* PID from my_popen */
+-
+- *noSubprocessP = FALSE;
+-
+- *fpP = my_popen(file_name + 1, mode, &thepid);
+- if (*fpP == NULL)
+- *errorP = "%s: can't invoke <<%s>> for %s: ";
+- else {
+- /* One more child to catch, eventually. */
+- if (*catchingChildrenP < MAX_CHILDREN)
+- pids[(*catchingChildrenP)++] = thepid;
+- }
+- } else if (cp > file_name && *cp == '.' && *(cp + 1) == 'Z' ) {
+- /* Compress case. */
+- pid_t thepid; /* PID from my_popen. */
+- const char * command;
+-
+- *noSubprocessP = FALSE;
+-
+- if (*mode == 'w')
+- pm_asprintf(&command, "compress > %s", file_name);
+- else if (*mode == 'a')
+- pm_asprintf(&command, "compress >> %s", file_name);
+- else
+- pm_asprintf(&command, "compress -d < %s", file_name);
+-
+- *fpP = my_popen(command, mode, &thepid);
+-
+- if (*fpP == NULL)
+- *errorP = "%s: can't invoke 'compress' program, "
+- "trying to open %s for %s";
+- else {
+- /* One more child to catch, eventually. */
+- if (*catchingChildrenP < MAX_CHILDREN)
+- pids[(*catchingChildrenP)++] = thepid;
+- }
+- pm_strfree(command);
+- } else {
+- *noSubprocessP = TRUE;
+- *errorP = NULL;
+- }
+-#endif
+ }
+
+
+diff --git a/urt/rle_putcom.c b/urt/rle_putcom.c
+index ab2eb20..ce83615 100644
+--- a/urt/rle_putcom.c
++++ b/urt/rle_putcom.c
+@@ -98,12 +98,14 @@ rle_putcom(const char * const value,
+ const char * v;
+ const char ** old_comments;
+ int i;
+- for (i = 2, cp = the_hdr->comments; *cp != NULL; ++i, ++cp)
++ for (i = 2, cp = the_hdr->comments; *cp != NULL; ++i, ++cp) {
++ overflow_add(i, 1);
+ if (match(value, *cp) != NULL) {
+ v = *cp;
+ *cp = value;
+ return v;
+ }
++ }
+ /* Not found */
+ /* Can't realloc because somebody else might be pointing to this
+ * comments block. Of course, if this were true, then the
+diff --git a/urt/scanargs.c b/urt/scanargs.c
+index f3af334..8dfa05b 100644
+--- a/urt/scanargs.c
++++ b/urt/scanargs.c
+@@ -62,8 +62,8 @@ typedef int *ptr;
+ /*
+ * Storage allocation macros
+ */
+-#define NEW( type, cnt ) (type *) malloc( (cnt) * sizeof( type ) )
+-#define RENEW( type, ptr, cnt ) (type *) realloc( ptr, (cnt) * sizeof( type ) )
++#define NEW( type, cnt ) (type *) malloc2( (cnt) , sizeof( type ) )
++#define RENEW( type, ptr, cnt ) (type *) realloc2( ptr, (cnt), sizeof( type ) )
+
+ static CONST_DECL char * prformat( CONST_DECL char *, int );
+ static int isnum( CONST_DECL char *, int, int );
+
diff --git a/netpbm-CAN-2005-2471.patch b/netpbm-CAN-2005-2471.patch
index 77a3cd7..de6bc59 100644
--- a/netpbm-CAN-2005-2471.patch
+++ b/netpbm-CAN-2005-2471.patch
@@ -1,8 +1,7 @@
-diff --git a/converter/other/pstopnm.c b/converter/other/pstopnm.c
-index f534265..2ab48ab 100644
---- a/converter/other/pstopnm.c
-+++ b/converter/other/pstopnm.c
-@@ -896,11 +896,11 @@ execGhostscript(int const inputPipeFd,
+diff -urNp a/converter/other/pstopnm.c b/converter/other/pstopnm.c
+--- a/converter/other/pstopnm.c 2025-02-04 10:47:27.857451432 +0100
++++ b/converter/other/pstopnm.c 2025-02-04 10:55:56.430470597 +0100
+@@ -896,11 +896,11 @@ execGhostscript(int const
ghostscriptProg, arg0,
deviceopt, outfileopt, gopt, ropt, textalphabitsopt,
"-q", "-dNOPAUSE",
@@ -10,10 +9,9 @@ index f534265..2ab48ab 100644
+ "-dPARANOIDSAFER", "-");
}
-- execl(ghostscriptProg, arg0, deviceopt, outfileopt, gopt, ropt,
-- textalphabitsopt, "-q", "-dNOPAUSE", "-dSAFER", "-", NULL);
-+ execl(ghostscriptProg, arg0, deviceopt, outfileopt, gopt, ropt, "-q",
-+ "-dNOPAUSE", "-dPARANOIDSAFER", "-", NULL);
+ execl(ghostscriptProg, arg0, deviceopt, outfileopt, gopt, ropt,
+- textalphabitsopt, "-q", "-dNOPAUSE", "-dSAFER", "-", NULL);
++ "-q", "-dNOPAUSE", "-dPARANOIDSAFER", "-", NULL);
pm_error("execl() of Ghostscript ('%s') failed, errno=%d (%s)",
ghostscriptProg, errno, strerror(errno));
diff --git a/netpbm-c99.patch b/netpbm-c99.patch
new file mode 100644
index 0000000..bcb8a99
--- /dev/null
+++ b/netpbm-c99.patch
@@ -0,0 +1,41 @@
+Remove the contents of libjasper_compat.c. The assignment
+
+ *errorP = errorP;
+
+is bogus because it creates a non-null value in *errorP even on
+success, and the caller expects a null pointer int his case.
+
+The source file is compiled, but not actually linked in, so this is
+only a problem because of the type error that fails the build.
+
+diff --git a/converter/other/jpeg2000/libjasper_compat.c b/converter/other/jpeg2000/libjasper_compat.c
+index 101820a321212dc6..e69de29bb2d1d643 100644
+--- a/converter/other/jpeg2000/libjasper_compat.c
++++ b/converter/other/jpeg2000/libjasper_compat.c
+@@ -1,26 +0,0 @@
+-#include "netpbm/nstring.h"
+-
+-#include "jasper/jasper.h"
+-#include "jasper/jas_image.h"
+-
+-#ifndef JAS_HAVE_PMJAS_IMAGE_DECODE
+-
+-void
+-pmjas_image_decode(jas_stream_t * const in,
+- int const fmtArg,
+- const char * const optstr,
+- jas_image_t ** const imagePP,
+- const char ** const errorP) {
+-
+- jas_image_t * const jasperP = jas_image_decode(in, fmtArg, optstr);
+-
+- if (jasperP) {
+- *imagePP = jasperP;
+- *errorP = errorP;
+- } else {
+- pm_asprintf(errorP, "Failed. Details may have been written to "
+- "Standard Error");
+- }
+-}
+-
+-#endif
diff --git a/netpbm-cmuwtopbm.patch b/netpbm-cmuwtopbm.patch
deleted file mode 100644
index f5b328b..0000000
--- a/netpbm-cmuwtopbm.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -up netpbm-10.61.01/converter/pbm/cmuwmtopbm.c.cmuwtopbmfix netpbm-10.61.01/converter/pbm/cmuwmtopbm.c
---- netpbm-10.61.01/converter/pbm/cmuwmtopbm.c.cmuwtopbmfix 2013-01-02 18:39:57.000000000 +0100
-+++ netpbm-10.61.01/converter/pbm/cmuwmtopbm.c 2013-01-03 05:41:36.024984241 +0100
-@@ -18,7 +18,7 @@
- This program does not check the pad bits at the end of each row.
- */
-
--
-+#include
- #include "pbm.h"
-
- /*--------------------------
-@@ -42,7 +42,7 @@ readCmuwmHeader(FILE * const ifP
- "CMU window manager header EOF / read error";
- uint32_t const cmuwmMagic = 0xf10040bb;
-
-- long l;
-+ uint32_t l;
- short s;
- int rc;
-
diff --git a/netpbm-glibc.patch b/netpbm-glibc.patch
index 4ae71e8..c500386 100644
--- a/netpbm-glibc.patch
+++ b/netpbm-glibc.patch
@@ -1,9 +1,10 @@
---- netpbm-10.35/converter/other/pnmtotiffcmyk.c.glibc 2006-09-18 12:20:06.000000000 +0200
-+++ netpbm-10.35/converter/other/pnmtotiffcmyk.c 2007-08-23 09:18:30.000000000 +0200
-@@ -974,8 +974,8 @@ int main( int argc, char **argv ) {
+diff -urNp a/converter/other/pnmtotiffcmyk.c b/converter/other/pnmtotiffcmyk.c
+--- a/converter/other/pnmtotiffcmyk.c 2025-02-04 10:47:27.858451429 +0100
++++ b/converter/other/pnmtotiffcmyk.c 2025-02-04 11:04:46.118394226 +0100
+@@ -989,8 +989,8 @@ int main( int argc, char **argv ) {
if ( (err = parseOpts( argc, argv, rt )) ) goto exit ;
-
+
- if ( (err = rt->in->open( rt->in, rt )) ) goto exit ;
- if ( (err = rt->out->open( rt->out, rt )) ) goto exit ;
+ if ( (err = (rt->in->open)( rt->in, rt )) ) goto exit ;
diff --git a/netpbm-manfix.patch b/netpbm-manfix.patch
index c28beb4..6d759c1 100644
--- a/netpbm-manfix.patch
+++ b/netpbm-manfix.patch
@@ -1,30 +1,20 @@
-diff --git a/userguide/avstopam.html b/userguide/avstopam.html
-index eb39766..d104518 100644
---- a/userguide/avstopam.html
-+++ b/userguide/avstopam.html
-@@ -2,25 +2,29 @@
+diff -urNp a/userguide/avstopam.html b/userguide/avstopam.html
+--- a/userguide/avstopam.html 2025-02-04 10:47:27.823451565 +0100
++++ b/userguide/avstopam.html 2025-02-04 17:49:34.981978989 +0100
+@@ -2,9 +2,9 @@
Avstopam User Manual
avstopam
-Updated: 07 February 2010
-
-+
-+Updated: 7 February 2010
+-Table Of Contents
++Updated: 07 February 2010
+
+Table Of Contents
-+
- Table Of Contents
NAME
--avstopam - convert an AVS X image to a Netpbm image
-+
avstopam - convert an AVS X image to a Netpbm image
-+
-
--SYNOPSIS
-+
-
- avstopam
- [avsfile]
+
avstopam - convert an AVS X image to a Netpbm image
+@@ -16,40 +16,40 @@ Updated: 07 February 2010
DESCRIPTION
@@ -37,8 +27,11 @@ index eb39766..d104518 100644
+image as output.
avsfile is the input file, which defaults to Standard Input.
- Output is always on Standard Output.
-@@ -30,26 +34,26 @@ Output is always on Standard Output.
+-Output is always on Standard Output.
++Output is always on Standard Output.
+
+ OPTIONS
+
There are no command line options defined specifically
for avstopam, but it recognizes the options common to all
programs based on libnetpbm (See
@@ -48,8 +41,8 @@ index eb39766..d104518 100644
AUTHOR
Copyright © 2010 Scott Pakin,
--scott+pbm@pakin.org.
-+scott+pbm@pakin.org.
+-scott+pbm@pakin.org
++scott+pbm@pakin.org
SEE ALSO
@@ -69,52 +62,229 @@ index eb39766..d104518 100644
+DESCRIPTION
+OPTIONS
+AUTHOR
-+SEE ALSO
++SEE ALSO
-diff --git a/userguide/escp2topbm.html b/userguide/escp2topbm.html
-index 9e808b7..33b19a0 100644
---- a/userguide/escp2topbm.html
-+++ b/userguide/escp2topbm.html
-@@ -8,6 +8,7 @@ Updated: 14 July 2015
-
- NAME
-
-+NAME
- escp2topbm - convert an ESC/P2 printer file to a PBM image
-
- SYNOPSIS
-diff --git a/userguide/faxformat.html b/userguide/faxformat.html
-index 44b1ba5..827ffc8 100644
---- a/userguide/faxformat.html
-+++ b/userguide/faxformat.html
+diff -urNp a/userguide/faxformat.html b/userguide/faxformat.html
+--- a/userguide/faxformat.html 2025-02-04 10:47:27.824451560 +0100
++++ b/userguide/faxformat.html 2025-02-04 17:50:41.300631089 +0100
@@ -5,10 +5,11 @@
Updated: 03 December 2008
-+SYNOPSIS
++SYNOPSIS
This page, part of the Netpbm user's guide,
describes FAX formats in relation to Netpbm facilities.
-
-+
DESCRIPTION
++DESCRIPTION
The ITU (formerly CCITT) publishes standards for operation of fax machines
(the idea is to provide a way to be sure that a fax machine is able to receive
a fax sent by another). These standards incidentally specify graphics file
-diff --git a/userguide/pampaintspill.html b/userguide/pampaintspill.html
-index eeb1cac..e42db76 100644
---- a/userguide/pampaintspill.html
-+++ b/userguide/pampaintspill.html
-@@ -2,12 +2,12 @@
-
Pampaintspill User Manual
-
- pampaintspill
--Updated: 09 February 2020
-+Updated: 09 February 2020
-
--Table Of Contents
-+Table Of Contents
+diff -urNp a/userguide/libnetpbm_ug.html b/userguide/libnetpbm_ug.html
+--- a/userguide/libnetpbm_ug.html 2025-02-04 10:47:27.824451560 +0100
++++ b/userguide/libnetpbm_ug.html 2025-02-04 17:52:02.045207328 +0100
+@@ -374,7 +374,7 @@ plain format.
+ Reference
+
+ The Libnetpbm Netpbm Image
+-Processing Manual describes the the libnetpbm functions for
++Processing Manual describes the libnetpbm functions for
+ processing image data.
+
+
The Libnetpbm Utility Manual
+diff -urNp a/userguide/pamfunc.html b/userguide/pamfunc.html
+--- a/userguide/pamfunc.html 2025-02-04 10:47:27.823451565 +0100
++++ b/userguide/pamfunc.html 2025-02-04 17:52:19.661114878 +0100
+@@ -60,7 +60,7 @@ output image.
+ and bit string (such as and with 01001000). For the arithmetic functions, the
+ function arguments and results are the fraction that a sample is of the
+ maxval, i.e. normal interpretation of PAM tuples. But for the bit string
+-functions, the value is the the bit string whose value as a binary cipher is
++functions, the value is the bit string whose value as a binary cipher is
+ the sample value, and the maxval indicates the width of the bit string.
+
+
Arithmetic functions
+diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
+--- a/userguide/pammixmulti.html 2025-02-04 10:47:27.820451577 +0100
++++ b/userguide/pammixmulti.html 2025-02-04 17:56:58.538651212 +0100
+@@ -7,8 +7,8 @@ Updated: 18 December 2024
+ Table Of Contents
+
+
+-NAME
+-pammixmulti - blend together multiple PAM images
++
NAME
++pammixmulti - blend together multiple PAM images
+
+
+ SYNOPSIS
+@@ -17,19 +17,19 @@ Updated: 18 December 2024
+ [-maskfile=filename]
+ [-stdev=number]
+ [-randomseed integer]
+- filename ...
++ filename ...
+
+ Minimum unique abbreviation of an option is acceptable. You can use double
+ hyphen instead of a single hyphen to denote options. You can use white
+ space in place of the equals sign to separate an option name from its
+-value.
++value.
+
+
+ DESCRIPTION
+-This file is part of Netpbm.
++
This file is part of Netpbm.
+
+ pammixmulti mixes two or more images to produce a new image. The
+-program provides multiple ways to interpret "mix."
++program provides multiple ways to interpret "mix."
+
+
+ OPTIONS
+@@ -37,7 +37,7 @@ program provides multiple ways to interp
+ In addition to the options common to all programs based on libnetpbm
+ (most notably -quiet, see
+ Common Options), pammixmulti recognizes the following
+-command line options:
++command line options:
+
+
+ - -blend=average|alpha-weighted|random|mask
+@@ -55,8 +55,8 @@ of the input images, chosen at random on
+ With -blend=mask, each pixel in the output is
+ produced by a weighted average of the corresponding pixels from all
+ the input images based on the grayscale level of an additional mask
+-image.
+--alpha-weighted was new in Netpbm 11.09 (December 2024).
++image.
++-alpha-weighted was new in Netpbm 11.09 (December 2024).
+
+
+ - -maskfile=filename
+@@ -66,7 +66,7 @@ grayscale mask file to control the blend
+ not grayscale, the first channel is treated as gray). Where the mask file is
+ black, the first image is selected. Where the mask file is white, the last
+ image is selected. Intermediate levels of gray select intermediate
+-images.
++images.
+
+
+ - -stdev=number
+@@ -83,7 +83,7 @@ that includes roughly equal amounts of t
+ and 2 but less of the corresponding pixel from image 3. As number
+ tends towards the number of input images (going beyond that has diminishing
+ impact), the output tends to look more
+-like -blend=average. number defaults to 0.25.
++like -blend=average. number defaults to 0.25.
+
+
+ - -randomseed integer
+@@ -91,45 +91,45 @@ like -blend=average. numberThis is the seed for the random number generator used with
+ -blend=random
+
+-
Use this to ensure you get the same image on separate invocations.
++
Use this to ensure you get the same image on separate invocations.
+
+
+
+ ARGUMENTS
+
+-You supply the names of the files to mix as non-option arguments.
++
You supply the names of the files to mix as non-option arguments.
+
+
+ EXAMPLES
+
+-Average a bunch of PPM images to produce a new PAM image:
++
Average a bunch of PPM images to produce a new PAM image:
+
+ pammixmulti input*.ppm >output.ppm
+
+
+ Mix these same images by taking each pixel from a randomly selected input
+-image:
++image:
+
+
+ pammixmulti -blend=random input*.ppm >output.ppm
+
+
+ Use a mask image to control the fading among input images on a
+-pixel-by-pixel basis:
++pixel-by-pixel basis:
+
+
+ pammixmulti -blend=mask -maskfile=mask.pgm >output.pam \
+ one.pam two.pam three.pam four.pam
+
+
+-Do the same but with more abrupt transitions:
++
Do the same but with more abrupt transitions:
+
+
+ pammixmulti -blend=mask -maskfile=mask.pgm -stdev=0.0 >output.pam \
+ one.pam two.pam three.pam four.pam
+
+
+-and now with more gradual transitions:
++
and now with more gradual transitions:
+
+
+ pammixmulti -blend=mask -maskfile=mask.pgm -stdev=1.0 >output.pam \
+@@ -139,12 +139,12 @@ pixel-by-pixel basis:
+
+ HISTORY
+
+-pammixmulti was new in Netpbm 10.85 (December 2018).
++
pammixmulti was new in Netpbm 10.85 (December 2018).
+
+
+ AUTHOR
+
+-Copyright 2018–2024 Scott Pakin, scott+pbm@pakin.org.
++
Copyright 2018–2024 Scott Pakin, scott+pbm@pakin.org.
+
+ SEE ALSO
+
+@@ -152,20 +152,20 @@ pixel-by-pixel basis:
+ ppmmix,
+ pamarith,
+ pnm,
+-pam
++pam
+
+
+ Table Of Contents
+
+
+
+
+diff -urNp a/userguide/pampaintspill.html b/userguide/pampaintspill.html
+--- a/userguide/pampaintspill.html 2025-02-04 10:47:27.823451565 +0100
++++ b/userguide/pampaintspill.html 2025-02-04 18:01:50.746117598 +0100
+@@ -7,7 +7,7 @@ Updated: 02 November 2021
+ Table Of Contents
NAME
-pampaintspill - smoothly spill colors into the background
@@ -122,12 +292,13 @@ index eeb1cac..e42db76 100644
SYNOPSIS
-@@ -16,31 +16,31 @@ pampaintspill - smoothly spill colors into the background
- [--bgcolor=color]
- [--wrap] [--all]
+@@ -19,48 +19,48 @@ pampaintspill - smoothly spill colors in
[--downsample=number]
--[--power=number] [filename]
-+[--power=number] [filename]
+ [--near=number]
+ [--power=number] [filename]
+-[-randomseed=integer]
++[-randomseed=integer]
+
Minimum unique abbreviations of option are acceptable. You may use
double hyphens instead of single hyphen to denote options. You may use
@@ -160,7 +331,9 @@ index eeb1cac..e42db76 100644
pampaintspill can produce tileable output and
can control how tightly the gradient colors bind to their source
-@@ -49,14 +49,14 @@ paint" onto the background. pampaintspill is similar to
+- pixels.
++ pixels.
+
Results are generally best when the input image contains just a few, crisp
spots of color. Use your drawing program's pencil tool — as opposed to a
@@ -177,40 +350,96 @@ index eeb1cac..e42db76 100644
- --bgcolor=color
-diff --git a/userguide/pamrecolor.html b/userguide/pamrecolor.html
-index 3f341d4..a5f2671 100644
---- a/userguide/pamrecolor.html
-+++ b/userguide/pamrecolor.html
-@@ -2,12 +2,15 @@
+@@ -117,45 +117,45 @@ command line options:
+ gradients away from them.
+
+ - -randomseed=integer
+-
- This is the seed for the random number generator that generates the
+- pixels.
++
- This is the seed fodr the random number generator that generates the
++ pixels.
+
+- Use this to ensure you get the same image on separate invocations.
++
Use this to ensure you get the same image on separate invocations.
+
+- This option was new in Netpbm 10.94 (March 2021).
++ This option was new in Netpbm 10.94 (March 2021).
+
+
+
+ SEE ALSO
+
+
+
+ HISTORY
+
+-pampaintspill was new in Netpbm 10.50 (March 2010).
++
pampaintspill was new in Netpbm 10.50 (March 2010).
+
+
+ COPYRIGHT
+
+ Copyright © 2010–2021 Scott Pakin,
+-scott+pbm@pakin.org.
++scott+pbm@pakin.org.
+
+ Table Of Contents
+
+
+
+
+diff -urNp a/userguide/pamrecolor.html b/userguide/pamrecolor.html
+--- a/userguide/pamrecolor.html 2025-02-04 10:47:27.823451565 +0100
++++ b/userguide/pamrecolor.html 2025-02-04 18:10:00.968545076 +0100
+@@ -2,9 +2,9 @@
Pamrecolor User Manual
pamrecolor
-Updated: 31 July 2010
--
++Updated: 31 July 2010
+
-Table Of Contents
++Table Of Contents
--NAME
--pamrecolor - alter colors without affecting luminance
-+Updated: 31 July 2010
-+
-+Table Of Contents
-+
-+
-+NAME
-+
-+pamrecolor - alter colors without affecting luminance
-
- SYNOPSIS
-
-@@ -22,6 +25,7 @@ pamrecolor - alter colors without affecting luminance
+ NAME
+ pamrecolor - alter colors without affecting luminance
+@@ -22,15 +22,15 @@ pamrecolor - alter colors without affect
[-randomseed=integer]
[infile]
+-
+
-
Minimum unique abbreviation of option is acceptable. You may use double
-@@ -30,7 +34,7 @@ space in place of the equals sign to separate an option name from its value.
+ hyphens instead of single hyphen to denote options. You may use white
+-space in place of the equals sign to separate an option name from its value.
++space in place of the equals sign to separate an option name from its value.
DESCRIPTION
@@ -219,16 +448,19 @@ index 3f341d4..a5f2671 100644
pamrecolor changes an image's colors to be as close as
possible to given target colors but with the constraint that the
-@@ -39,7 +43,7 @@ image will look identical if both are converted to grayscale
+@@ -39,17 +39,17 @@ image will look identical if both are co
(e.g. with
ppmtopgm). You can have pamrecolor select
target colors randomly, specify a single hue for the entire image, or take the
-target colors from a target image.
+target colors from a target image.
- pamrecolor works on pseudo-Netpbm images based on arbitrary
- color spaces. You can define the color space explicitly or choose one
-@@ -49,7 +53,7 @@ of many that pamrecolor knows by name.
+
In addition to real Netpbm images, pamrecolor works on pseudo-Netpbm
+ images based on arbitrary color spaces. You can define the color space
+-explicitly or choose one of many that pamrecolor knows by name.
++explicitly or choose one of many that pamrecolor knows by name.
+
+ The output is a PAM image on standard output. Options control the
exact format of the PAM. If you want a PNM (PBM, PGM, or PPM) image,
use pamtopnm on the output. There is no
need to convert if you will use the image as input to a current Netpbm
@@ -237,7 +469,7 @@ index 3f341d4..a5f2671 100644
OPTIONS
-@@ -57,7 +61,7 @@ program, but many other programs don't know what a PAM is.
+@@ -57,7 +57,7 @@ program, but many other programs don't k
In addition to the options common to all programs based on libnetpbm
(most notably -quiet, see
Common Options), pamrecolor recognizes the following
@@ -246,7 +478,28 @@ index 3f341d4..a5f2671 100644
-@@ -109,12 +113,12 @@ the format that uses sRGB.
+@@ -67,7 +67,7 @@ to luminance of each of the red, green,
+ example, in the SMPTE-C color space an RGB color is converted to
+ grayscale by multiplying the red channel by 0.2124132, the green
+ channel by 0.7010437, and the blue channel by 0.0865432 and summing
+-the resulting three products.
++the resulting three products.
+
+ When you use this option, the input and output images are not true Netpbm
+ images, because the Netpbm image format specifies a particular color space.
+@@ -76,9 +76,9 @@ the raster have different meaning. Many
+ images actually use a variation with a different color space. For example,
+ GIMP uses sRGB internally and if you
+ have GIMP generate a Netpbm image file, it really generates a variation of
+-the format that uses sRGB.
++the format that uses sRGB.
+
+-pamrecolor knows the following color spaces (name values):
++
pamrecolor knows the following color spaces (name values):
+
+
+ - adobe
+@@ -109,12 +109,12 @@ the format that uses sRGB.
The default is "ntsc" because this is the color space that the Netpbm
formats and many graphics utilities use. As a counterexample,
GIMP uses sRGB as its native color
@@ -257,29 +510,64 @@ index 3f341d4..a5f2671 100644
Bruce Lindbloom's
-Computing RGB-to-XYZ and XYZ-to-RGB matrices page.
-+Computing RGB-to-XYZ and XYZ-to-RGB matrices page.
++Computing RGB-to-XYZ and XYZ-to-RGB matrices page.
- --rmult=fraction
- --gmult=fraction
-@@ -137,7 +141,7 @@ library routine (e.g., "hotpink" or "#ff69b4").
+@@ -133,15 +133,13 @@ image. pamrecolor will make each
+ to color subject to the constraint that the luminance must stay the
+ same as in the original image. Specify color as in
+ the argument of the pnm_parsecolor()
+-library routine (e.g., "hotpink" or "#ff69b4").
++library routine (e.g., "hotpink" or "#ff69b4").
+
+ If you specify neither --targetcolor nor
+ --colorfile, pamrecolor will randomly select a target color for
+-each pixel of the input image.
+-
+-
You may not specify both -targetcolor and -colorfile.
++each pixel of the input image.
+
+-
++You may not specify both -targetcolor and -colorfile.
+
+ - --colorfile=file
+ - Take per-pixel target colors from Netpbm file file instead
+@@ -150,40 +148,38 @@ of using a single target color for the e
+ If the image in the file wider or taller than the input image,
+ pamrecolor uses only the left and top part of it.
+ If the image is narrower or shorter, pamrecolor considers the
+-image to be repeated in a tile pattern.
++image to be repeated in a tile pattern.
If you specify neither --targetcolor nor
--colorfile, pamrecolor will randomly select a target color for
-each pixel of the input image.
+each pixel of the input image.
- You may not specify both -targetcolor and -colorfile.
+-
You may not specify both -targetcolor and -colorfile.
++
You may not specify both -targetcolor and -colorfile.
-@@ -154,7 +158,7 @@ image to be repeated in a tile pattern.
+-- -randomseed=integer
++
- -randomseed=integer
- If you specify neither --targetcolor nor
- --colorfile, pamrecolor will randomly select a target color for
--each pixel of the input image.
-+each pixel of the input image.
+ - This is the seed for the random number generator that generates the
+-pixels.
++pixels.
- You may not specify both -targetcolor and -colorfile.
+-
Use this to ensure you get the same image on separate invocations.
++
Use this to ensure you get the same image on separate invocations.
+
+ By default, pamrecolor uses a seed derived from the time of day
+ and process ID, which gives you fairly uncorrelated results in multiple
+-invocations.
+-
+-
This option was new in Netpbm 10.61 (December 2012).
++invocations.
+
+-
++This option was new in Netpbm 10.61 (December 2012).
-@@ -176,23 +180,23 @@ invocations.
EXAMPLES
@@ -287,8 +575,7 @@ index 3f341d4..a5f2671 100644
+This command tints an image yellow:
-- pamrecolor --targetcolor=yellow colorpic.pam > yellowpic.pam
-+ pamrecolor --targetcolor=yellow colorpic.pam > yellowpic.pam
+ pamrecolor --targetcolor=yellow colorpic.pam > yellowpic.pam
This command takes the colors from colorpicture.ppm and applies
@@ -296,10 +583,8 @@ index 3f341d4..a5f2671 100644
+them to graypicture.pgm:
-- pamrecolor --colorfile=colorpic.ppm graypic.pgm > colorizedpic.pam
-+ pamrecolor --colorfile=colorpic.ppm graypic.pgm > colorizedpic.pam
-
-
+ pamrecolor --colorfile=colorpic.ppm graypic.pgm > colorizedpic.pam
+@@ -192,52 +188,52 @@ them to graypicture.pgm:
The grayscale version of colorizedpic.pam will look just like
graypic.pgm. Note that if you use a non-Netpbm tool to do the conversion to
grayscale, you may additionally need to specify an
@@ -308,7 +593,11 @@ index 3f341d4..a5f2671 100644
NOTES
-@@ -203,25 +207,25 @@ appropriate --colorspace value for your conversion tool.
+
+ Here are a couple of fun special effects you can produce with
+-pamrecolor:
++pamrecolor:
+
- Specify a color file that is identical to the input image but with
some large, colored text added to it. The text will "magically"
@@ -336,18 +625,30 @@ index 3f341d4..a5f2671 100644
-
Scott Pakin wrote pamrecolor in July 2010.
+
Scott Pakin wrote pamrecolor in July 2010.
- pamrecolor was new in Netpbm 10.52 (September 2010).
+-
pamrecolor was new in Netpbm 10.52 (September 2010).
++
pamrecolor was new in Netpbm 10.52 (September 2010).
+
-@@ -229,7 +233,7 @@ photograph of the late 1800s).
AUTHOR
Copyright (C) 2010 Scott
--Pakin, scott+pbm@pakin.org.
-+Pakin, scott+pbm@pakin.org.
+-Pakin, scott+pbm@pakin.org
++Pakin, scott+pbm@pakin.org
SEE ALSO
-@@ -246,14 +250,14 @@ Pakin, scott+pbm@pakin.org.
+
+
+
+
+@@ -246,14 +242,14 @@ Pakin, Table Of Contents
@@ -370,1632 +671,39 @@ index 3f341d4..a5f2671 100644
-diff --git a/userguide/pamsistoaglyph.html b/userguide/pamsistoaglyph.html
-index 1ca53ac..e545986 100644
---- a/userguide/pamsistoaglyph.html
-+++ b/userguide/pamsistoaglyph.html
-@@ -1,15 +1,18 @@
-
- Pamsistoaglyph User Manual
-
-+
- pamsistoaglyph
--Updated: 05 April 2009
--
--Table Of Contents
-+
-+Updated: 5 April 2009
-+
-+Table Of Contents
-+
-
- NAME
-
--pamsistoaglyph - convert a single-image stereogram to a red/cyan
--anaglyphic image
-+pamsistoaglyph - convert a single-image stereogram to a red/cyan
-+anaglyphic image
-
-
- SYNOPSIS
-@@ -20,11 +23,11 @@ anaglyphic image
- [--minsep=number]
- [--gray=number]
- [in_netpbmfile
--
-+
-
- All options can be abbreviated to their shortest unique prefix. You
- may use either white space or an equals sign between an option name
--and its value.
-+and its value.
-
-
- DESCRIPTION
-@@ -32,7 +35,7 @@ and its value.
- This program is part of Netpbm.
-
-
pamsistoaglyph reads a Netpbm image as input and
--produces a Netpbm image as output.
-+produces a Netpbm image as output.
-
- pamsistoaglyph takes a single-image stereogram
- (SIS) such as those produced by pamsistoaglyph is to help people who have trouble
--viewing single-image stereograms see the intriguing 3-D effect.
-+viewing single-image stereograms see the intriguing 3-D effect.
-
- pamsistoaglyph can convert single-image random-dot
- stereograms (SIRDS), wallpaper stereograms, and even dual-image
--stereograms to anaglyphic images.
-+stereograms to anaglyphic images.
-
-
- OPTIONS
-@@ -57,13 +60,13 @@ stereograms to anaglyphic images.
- In addition to the options common to all programs based on libnetpbm
- (most notably -quiet, see
- Common Options), pamsistoaglyph recognizes the following
--command line options:
-+command line options:
-
- For most images, no command-line options need to be specified. The
--following options are available, however, for unusual circumstances.
-+following options are available, however, for unusual circumstances.
-
-
--- --invert
-+
- --invert
- - Swap the left- and right-eye
- images. pamsistoaglyph assumes that its input
- represents a wall-eyed stereogram and generates the anaglyphic
-@@ -71,17 +74,17 @@ following options are available, however, for unusual circumstances.
- the page where it should pop out of the page (and vice versa),
- this typically implies that the input image represents a
- cross-eyed stereogram. Use --invert to correct
-- the image depth.
-+ the image depth.
-
--- --sep=number
-+
- --sep=number
- - Specify the distance in pixels between the left- and right-eye
- images. Essentially, this corresponds to the distance between
- repetitions of the background pattern. The --sep
- option should rarely be necessary
- as pamsistoaglyph is fairly good at determining
-- automatically the eye-separation distance.
-+ automatically the eye-separation distance.
-
--- --minsep=number
-+
- --minsep=number
- - This option is similar to --sep but
- constrains pamsistoaglyph only to
- a minimum eye-separation distance. Any distance larger
-@@ -90,9 +93,9 @@ following options are available, however, for unusual circumstances.
- as pamsistoaglyph is fairly good at determining
- automatically the eye-separation distance. The default value for
- the minimum eye-separation distance is 10% of the image width;
-- this value seems to work well in practice.
-+ this value seems to work well in practice.
-
--- --gray=number
-+
- --gray=number
- - Limit the number of gray levels to use when searching for the
- optimal eye-separation
- distance. Because pamsistoaglyph looks for
-@@ -103,7 +106,7 @@ following options are available, however, for unusual circumstances.
- unintentional color variations (such as those caused by conversion
- from a low-quality JPEG image, for example). The default of 63
- seems to work well so the --gray option should
-- rarely be necessary.
-+ rarely be necessary.
-
-
-
-@@ -112,22 +115,22 @@ following options are available, however, for unusual circumstances.
- The registration algorithm used by pamsistoaglyph
- was developed specifically for this program. As far as the author
- knows, there are no existing algorithms for converting stereograms to
--anaglyphs. The algorithm works as follows:
-+anaglyphs. The algorithm works as follows:
-
-
- - Convert the image to grayscale to increase the ability to identify
-- matches.
-+ matches.
-
- - Count the number of pixels that match N pixels ahead in the
-- image for all N in [1, width/2].
-+ image for all N in [1, width/2].
-
- - Maintain a running mean (μ) and standard deviation (σ) of
-- the number of matched pixels.
-+ the number of matched pixels.
-
- - Store the N corresponding to each spike in the number of
- matched pixels. A spike is defined as a tally that exceeds the
- mean plus one, two, or three standard deviations. Only the first
-- spike of a given standard-deviation multiplier is stored.
-+ spike of a given standard-deviation multiplier is stored.
-
- - If a tally greater than μ+3σ was encountered, return the
- corresponding N. If not, then if a tally greater than
-@@ -138,13 +141,13 @@ anaglyphs. The algorithm works as follows:
- produces the minimum average distance between matched pixels
- (i.e., #matches divided by #pixels). If no
- such N exceeds the minimum allowable eye-separation value,
-- return zero to indicate failure.
-+ return zero to indicate failure.
-
- - If the algorithm returned zero, rerun the algorithm independently
- on each row of the input image and return the median of
- all N that exceed the minimum allowable eye-separation
- value. If no such N exists, abort with an error
-- message.
-+ message.
-
-
- HISTORY
-@@ -156,7 +159,7 @@ in Netpbm in Release 10.47 (June 2009).
- AUTHOR
-
- Copyright (C) 2009 Scott
--Pakin, scott+pbm@pakin.org.
-+Pakin, scott+pbm@pakin.org.
-
-
- SEE ALSO
-@@ -174,13 +177,13 @@ Pakin, scott+pbm@pakin.org.
- Table Of Contents
-
-
-
-
-diff --git a/userguide/pamtoavs.html b/userguide/pamtoavs.html
-index 5d0ae35..bee1a40 100644
---- a/userguide/pamtoavs.html
-+++ b/userguide/pamtoavs.html
-@@ -2,13 +2,15 @@
- Pamtoavs User Manual
-
- pamtoavs
--Updated: 07 February 2010
--
--Table Of Contents
-+
-+Updated: 7 February 2010
-+
-+Table Of Contents
-+
-
- NAME
-
--pamtoavs - convert a Netpbm image to an AVS X image
-+
pamtoavs - convert a Netpbm image to an AVS X image
-
- SYNOPSIS
-
-@@ -17,7 +19,7 @@ Updated: 07 February 2010
-
- DESCRIPTION
-
--This program is part of Netpbm.
-+
This program is part of Netpbm.
-
- pamtoavs reads a Netpbm image as input and produces a Stardent
- AVS
-@@ -27,14 +29,14 @@ href="http://www.gnuplot.info/">Gnuplot v4.2 and later can use.
-
netpbmfile is the input file, which defaults to Standard Input.
- Output is always on Standard Output.
-
--
Try the following:
-+
Try the following:
-
-
- gnuplot> plot 'myimage.avs' binary filetype=avs with rgbimage
-
-
- See the Gnuplot
--manual for more information.
-+manual for more information.
-
-
- OPTIONS
-@@ -42,29 +44,29 @@ manual for more information.
- There are no command line options defined specifically
- for pamtoavs, but it recognizes the options common to all
- programs based on libnetpbm (See
--Common Options.)
-+Common Options.)
-
- AUTHOR
-
- Copyright © 2010 Scott Pakin,
--scott+pbm@pakin.org.
-+scott+pbm@pakin.org.
-
- SEE ALSO
-
- avstopam,
- gnuplot,
--pam
-+pam
-
-
-
- Table Of Contents
-
-
-
-
-diff --git a/userguide/pamtooctaveimg.html b/userguide/pamtooctaveimg.html
-index 4e09e8e..d2cc50b 100644
---- a/userguide/pamtooctaveimg.html
-+++ b/userguide/pamtooctaveimg.html
-@@ -2,13 +2,13 @@
- Pamtooctaveimg User Manual
-
- pamtooctaveimg
--
--Updated: 27 June 2007
--Table Of Contents
-+
-+
Updated: 27 June 2007
-+Table Of Contents
-
- NAME
-
--pamtooctaveimg - convert a Netpbm image to a GNU Octave image
-+
pamtooctaveimg - convert a Netpbm image to a GNU Octave image
-
- SYNOPSIS
-
-@@ -17,7 +17,7 @@
-
- DESCRIPTION
-
--This program is part of Netpbm.
-+
This program is part of Netpbm.
-
- pamtooctaveimg reads a Netpbm image as input and produces a GNU Octave image file as output.
-@@ -45,7 +45,7 @@ Image Processing chapter of the GNU Octave manual for details.
-
There are no command line options defined specifically
- for pamtooctaveimg, but it recognizes the options common to all
- programs based on libnetpbm (See
--Common Options.)
-+Common Options.)
-
- ARGUMENTS
-
-@@ -77,7 +77,8 @@ specify netpbmfile, the input is from Standard Input.
- NOTES
-
- There is no octavetopam program. However, GNU Octave's
--saveimage command can save images in PPM format.
-+saveimage command can save images in PPM format.
-+
-
+diff -urNp a/userguide/pbmtog3.html b/userguide/pbmtog3.html
+--- a/userguide/pbmtog3.html 2025-02-04 10:47:27.827451549 +0100
++++ b/userguide/pbmtog3.html 2025-02-04 18:10:55.328259786 +0100
+@@ -80,7 +80,7 @@ You cannot specify both.
HISTORY
-@@ -86,7 +87,7 @@ specify netpbmfile, the input is from Standard Input.
- AUTHOR
+ Before Netpbm 10.79 (June 2017), there was a different program by the same
+-name in Netpbm, which was written by by Paul Haeberli
++name in Netpbm, which was written by Paul Haeberli
+ <paul@manray.sgi.com> in 1989
+ and then modified extensively by others.
-
Copyright (C) 2007 Scott Pakin,
--scott+pbm@pakin.org.
-+scott+pbm@pakin.org.
-
- SEE ALSO
-
-@@ -98,15 +99,15 @@ href="http://www.gnu.org/software/octave/doc/interpreter/index.html">octave
-
- Table Of Contents
-
-
-
-diff --git a/userguide/pnmflip.html b/userguide/pnmflip.html
-index 2bd7368..8a1916e 100644
---- a/userguide/pnmflip.html
-+++ b/userguide/pnmflip.html
-@@ -5,17 +5,18 @@
-
- NAME
-
--pnmflip - replaced by pamflip
-+pnmflip - replaced by pamflip
-
- DESCRIPTION
-
--This program is part of Netpbm.
-+
This program is part of Netpbm.
-
- pnmflip was replaced in Netpbm 10.13 (December 2002) by
- pamflip.
-
-+
DESCRIPTION
- pamflip is mostly backward compatible with pnmflip,
--but works on PAM images too.
-+but works on PAM images too.
-
- One way pamflip is not backward compatible with pnmflip
- is that pnmflip lets you specify any number of basic flip options,
-@@ -23,12 +24,12 @@ whereas pamflip requires exactly one. (pamflip provides
- the -xform option for requesting multiple transformations, though).
- Because of this incompatibility, pnmflip still exists as a
- separate program, and all it does is translate its options to pamflip
--style and run pamflip.
-+style and run pamflip.
-
- You should not make any new use of pnmflip and if you modify an
- existing use, you should upgrade to pamflip. But note that if you
- write a program that might have to be used with very old
--Netpbm, pnmflip is the only way to do that.
-+Netpbm, pnmflip is the only way to do that.
-
-
-
-diff --git a/userguide/pnmmercator.html b/userguide/pnmmercator.html
-index 998f7fb..65576ac 100644
---- a/userguide/pnmmercator.html
-+++ b/userguide/pnmmercator.html
-@@ -18,11 +18,12 @@ projection and vice-versa
- [filename]
-
- Minimum unique abbreviation of option is acceptable.
--You may use double hyphens instead of single hyphen to denote options.
-+You may use double hyphens instead of single hyphen to denote options.
-
- DESCRIPTION
-
--This program is part of Netpbm.
-+
This program is part of Netpbm.
-
- The pnmmercator utility, converts a rectangular projection worldmap
- to a Mercator projection format, as used for maps.google.com and many other
-@@ -31,34 +32,34 @@ online maps. The map used as input for pnmmercator must have rows for
- file will typically be twice as wide as high, but this is not a
- requirement. The output file will be using the Mercator
--projection and will get double the height of the input file.
-+projection and will get double the height of the input file.
-
- Maps using the Mercator projection are stretched more the closer a row is
- to the North or South Pole. The last few degrees (> 85 or < -85 degrees)
- are not part of a Mercator map at all because they would be stretched too much
- and the rows close to the edge will show banding, because they originate from
--the same row in the original map.
-+the same row in the original map.
-
- To overcome this, the program will by default do interpolation of pixel
- colors, which will eliminate the banding effect, but will cause some blurring
- of the output. With the -nomix option, this interpolation of colors isn't
- applied. You can obtain the highest quality output by starting with an input
- map of high resolution, so that you can follow the pnmmercator
--transformation with a pamscale reduction in size.
-+transformation with a pamscale reduction in size.
-
- This program can also convert a Mercator projection map back to a
- rectangular projection based. As said, the Mercator map doesn't have
- information about the latitudes close to the poles. Therefore the top rows in
- the output image will be identical and copied from the row corresponding with
--latitude of 85 degrees. The same at the bottom of the map.
-+latitude of 85 degrees. The same at the bottom of the map.
-
- Pnmmercator doesn't have any provision for scaling the image. You can scale
- by piping the output of the program through Netpbm programs such as
--pamscale.
-+pamscale.
-
- You can find maps to be used as input at flatplanet.sourceforge.net
--or uic.edu/pape.
-+or uic.edu/pape.
-
- The point of a Mercator projection map is that compass directions work on
- it. If you draw a straight line northeast from some point on the Mercator
-@@ -78,33 +79,33 @@ proportional to angular longitude.
-
PARAMETERS
-
- filename is the name of the input file. If you don't specify
--this, pnmmercator reads the image from standard Input.
-+this, pnmmercator reads the image from standard Input.
-
- OPTIONS
-
- In addition to the options common to all programs based on libnetpbm
- (most notably -quiet, see
- Common Options), pnmmercator recognizes the following
--command line options:
-+command line options:
-
-
- - -inverse
- -
-
With this option a conversion from Mercator to degrees is applied.The
--output image will have half the height of the input map.
-+output image will have half the height of the input map.
-
- - -nomix
- -
-
Default behaviour is that color blending is applied in between two adjacent
- rows. If you specify the -nomix parameter there is no blending. The
- consequence is a banding at the top and bottom of the map. With this option,
--the output map will also consist of exactly the same colors as the input.
-+the output map will also consist of exactly the same colors as the input.
-
- - -verbose and -vverbose
- -
-
This parameter outputs some additional information. If you double the 'v',
- it will output debug data about the lat/long degree and Mercator
--conversions.
-+conversions.
-
-
-
-@@ -114,25 +115,26 @@ conversions.
- ppmglobe
-
- HISTORY
--pnmmercator was new in Netpbm 10.49 (December 2009).
-+
pnmmercator was new in Netpbm 10.49 (December 2009).
-
- AUTHORS
-
- Willem van Schaik (of
- pnmtopng/pngtopnm fame) wrote this program in October 2009 and
--suggested it for inclusion in Netpbm.
-+suggested it for inclusion in Netpbm.
-
-
-
- Table Of Contents
-
-
-