2011.12.21 14:52 "[Tiff] Proposed patch for ppm2tiff", by Jürgen_Buchmüller

2011.12.21 17:55 "Re: [Tiff] Proposed patch for ppm2tiff", by Jürgen_Buchmüller

On Wed, 21 Dec 2011 10:08:36 -0600 (CST) Bob Friesenhahn <bfriesen@simple.dallas.tx.us> wrote:

> Since there is only one useful mode option, I suggest that the '-m a' > option be changed to a simple flag like '-a' for append. Can you

> incorporate that in your patch?

Sure. There are more - possibly useful - mode options, though. The list of options given in TIFFOpen(3TIFF) like l,b to change the byte order, m to disable memory mapped files, perhaps h to skip some parsing overhead (untested).

Juergen

--
Jürgen Buchmüller <pullmoll@t-online.de>

--- tiff_3_9_1.old/tools/ppm2tiff.c     2006-04-20 14:36:23.000000000 +0200

+++ tiff_3_9_1/tools/ppm2tiff.c 2011-12-21 17:32:15.253265669 +0100

@@ -75,6 +75,7 @@
        uint32 rowsperstrip = (uint32) -1;
        double resolution = -1;
        unsigned char *buf = NULL;

+       uint32 tiff_append = 0;

        tsize_t linebytes = 0;
        uint16 spp = 1;
        uint16 bpp = 8;

@@ -90,8 +91,11 @@

            fprintf(stderr, "%s: Too few arguments\n", argv[0]);
            usage();
        }

-       while ((c = getopt(argc, argv, "c:r:R:")) != -1)

+       while ((c = getopt(argc, argv, "ac:r:R:")) != -1)

                switch (c) {

+               case 'a':
+                       tiff_append = 1;
+                       break;

                case 'c': /* compression scheme */
                        if (!processCompressOptions(optarg))
                                usage();

@@ -190,7 +194,7 @@

                        BadPPM(infile);
                break;
        }

-       out = TIFFOpen(argv[optind], "w");

+       out = TIFFOpen(argv[optind], tiff_append ? "a" : "w");

        if (out == NULL)
                return (-4);
        TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) w);

@@ -319,6 +323,7 @@

 char* stuff[] = {
 "usage: ppm2tiff [options] input.ppm output.tif",
 "where options are:",

+" -a open the output.tif in append mode",

 " -r #         make each strip have no more than # rows",
 " -R #         set x&y resolution (dpi)",

 "",