int
main(int argc, char* argv[])
{
	TIFF *in, *out;
	int c;
	extern int optind;
	extern char *optarg;

	while ((c = getopt(argc, argv, "c:h:r:v:z")) != -1)
		switch (c) {
		case 'c':
			if (streq(optarg, "none"))
			    compression = COMPRESSION_NONE;
			else if (streq(optarg, "packbits"))
			    compression = COMPRESSION_PACKBITS;
			else if (streq(optarg, "lzw"))
			    compression = COMPRESSION_LZW;
			else if (streq(optarg, "jpeg"))
			    compression = COMPRESSION_JPEG;
			else if (streq(optarg, "zip"))
			    compression = COMPRESSION_ADOBE_DEFLATE;
			else
			    usage(-1);
			break;
		case 'h':
			horizSubSampling = atoi(optarg);
			break;
		case 'v':
			vertSubSampling = atoi(optarg);
			break;
		case 'r':
			rowsperstrip = atoi(optarg);
			break;
		case 'z':	/* CCIR Rec 601-1 w/ headroom/footroom */
			refBlackWhite[0] = 16.;
			refBlackWhite[1] = 235.;
			refBlackWhite[2] = 128.;
			refBlackWhite[3] = 240.;
			refBlackWhite[4] = 128.;
			refBlackWhite[5] = 240.;
			break;
		case '?':
			usage(0);
			/*NOTREACHED*/
		}
	if (argc - optind < 2)
		usage(-1);
	out = TIFFOpen(argv[argc-1], "w");
	if (out == NULL)
		return (-2);
	setupLumaTables();
	for (; optind < argc-1; optind++) {
		in = TIFFOpen(argv[optind], "r");
		if (in != NULL) {
			do {
				if (!tiffcvt(in, out) ||
				    !TIFFWriteDirectory(out)) {
					(void) TIFFClose(out);
					return (1);
				}
			} while (TIFFReadDirectory(in));
			(void) TIFFClose(in);
		}
	}
	(void) TIFFClose(out);
	return (0);
}
Example #2
0
int
main(int argc, char* argv[])
{
    TIFF *in, *out;
    int c;
    extern int optind;
    extern char *optarg;

    while ((c = getopt(argc, argv, "c:r:t:bn")) != -1)
        switch (c) {
          case 'b':
            process_by_block = 1;
            break;
            
          case 'c':
            if (streq(optarg, "none"))
                compression = COMPRESSION_NONE;
            else if (streq(optarg, "packbits"))
                compression = COMPRESSION_PACKBITS;
            else if (streq(optarg, "lzw"))
                compression = COMPRESSION_LZW;
            else if (streq(optarg, "jpeg"))
                compression = COMPRESSION_JPEG;
            else if (streq(optarg, "zip"))
                compression = COMPRESSION_DEFLATE;
            else
                usage(-1);
            break;

          case 'r':
            rowsperstrip = atoi(optarg);
            break;

          case 't':
            rowsperstrip = atoi(optarg);
            break;
            
          case 'n':
            no_alpha = 1;
            break;
            
          case '?':
            usage(0);
            /*NOTREACHED*/
        }

    if (argc - optind < 2)
        usage(-1);

    out = TIFFOpen(argv[argc-1], "w");
    if (out == NULL)
        return (-2);

    for (; optind < argc-1; optind++) {
        in = TIFFOpen(argv[optind], "r");
        if (in != NULL) {
            do {
                if (!tiffcvt(in, out) ||
                    !TIFFWriteDirectory(out)) {
                    (void) TIFFClose(out);
                    return (1);
                }
            } while (TIFFReadDirectory(in));
            (void) TIFFClose(in);
        }
    }
    (void) TIFFClose(out);
    return (0);
}