--- poppler-0.15.2/configure.ac- 2010-11-12 23:18:48.000000000 +0100 +++ poppler-0.15.2/configure.ac 2010-11-28 21:19:48.163282017 +0100 @@ -172,6 +172,37 @@ AH_TEMPLATE([ENABLE_LIBOPENJPEG], [Use libopenjpeg instead of builtin jpeg2000 decoder.]) +dnl ##### Test for libtiff +AC_ARG_ENABLE(libtiff, + AC_HELP_STRING([--disable-libtiff], + [Don't build against libtiff.]), + enable_libtiff=$enableval, + enable_libtiff="try") + +if test x$enable_libtiff = xyes; then + AC_CHECK_LIB([tiff], [TIFFOpen],, + AC_MSG_ERROR("*** libtiff library not found ***")) + AC_CHECK_HEADERS([tiffio.h],, + AC_MSG_ERROR("*** libtiff headers not found ***")) +elif test x$enable_libtiff = xtry; then + AC_CHECK_LIB([tiff], [TIFFOpen], + [enable_libtiff="yes"], + [enable_libtiff="no"]) + AC_CHECK_HEADERS([tiffio.h],, + [enable_libtiff="no"]) +fi + +if test x$enable_libtiff = xyes; then + LIBTIFF_LIBS="-ltiff" + AC_SUBST(LIBTIFF_LIBS) + AC_DEFINE(ENABLE_LIBTIFF) +fi + +AM_CONDITIONAL(BUILD_LIBTIFF, test x$enable_libtiff = xyes) +AH_TEMPLATE([ENABLE_LIBTIFF], [Build against libtiff.]) +if test x$enable_libtiff = xyes; then + AC_DEFINE(ENABLE_LIBTIFF, 1, [Build against libtiff.]) +fi dnl ##### Checks for library functions. AC_CHECK_FUNCS(popen mkstemp mkstemps) @@ -685,6 +716,7 @@ echo " use gtk-doc: $enable_gtk_doc" echo " use libjpeg: $enable_libjpeg" echo " use libpng: $enable_libpng" +echo " use libtiff: $enable_libtiff" echo " use zlib: $enable_zlib" echo " use libcurl: $enable_libcurl" echo " use libopenjpeg: $enable_libopenjpeg" --- poppler-0.15.2/poppler/Makefile.am- 2010-11-12 23:19:37.000000000 +0100 +++ poppler-0.15.2/poppler/Makefile.am 2010-11-28 21:26:44.488619938 +0100 @@ -73,6 +73,15 @@ endif +if BUILD_LIBTIFF + +libtiff_libs = \ + $(LIBTIFF_LIBS) +libtiff_includes = \ + $(LIBTIFF_CFLAGS) + +endif + if BUILD_LIBOPENJPEG libjpeg2000_sources = \ @@ -147,6 +156,7 @@ $(cairo_includes) \ $(arthur_includes) \ $(abiword_includes) \ + $(libtiff_includes) \ $(libpng_includes) \ $(libcurl_includes) \ $(FREETYPE_CFLAGS) \ @@ -165,6 +175,7 @@ $(top_builddir)/fofi/libfofi.la \ $(cms_libs) \ $(splash_libs) \ + $(libtiff_libs) \ $(libjpeg_libs) \ $(libpng_libs) \ $(zlib_libs) \ --- poppler-0.15.2/splash/SplashBitmap.cc- 2010-11-04 01:01:08.000000000 +0100 +++ poppler-0.15.2/splash/SplashBitmap.cc 2010-11-28 20:15:53.088659649 +0100 @@ -417,3 +417,229 @@ return splashOk; } + +#if ENABLE_LIBTIFF + +//------------------------------------------------------------------------ +// SplashBitmap TIFF procedures +//------------------------------------------------------------------------ + +#include "tiffio.h" + +// Write a TIFF file. +// If openedFile is not NULL, try to use it, otherwise open fileName + +SplashError SplashBitmap::writeTIFFile(FILE *openedFile, char *fileName, double hDPI, double vDPI, const char *compressionStr) { + SplashColorPtr row, p; + int x, y; + + unsigned int compression; + uint16 photometric; + uint32 rowsperstrip = (uint32) -1; + tsize_t bytesperline; + tsize_t tiffLineLen; + int bitspersample; + uint16 samplesperpixel; + TIFF *f; + unsigned char *tiffLine, *tiffLinePtr; + static struct compression_name_tag { + const char *compressionName; + unsigned int compressionCode; + const char *compressionDescription; + } compressionList[] = { + { "none", COMPRESSION_NONE, "no compression" }, + { "ccittrle", COMPRESSION_CCITTRLE, "CCITT modified Huffman RLE" }, + { "ccittfax3", COMPRESSION_CCITTFAX3,"CCITT Group 3 fax encoding" }, + { "ccittt4", COMPRESSION_CCITT_T4, "CCITT T.4 (TIFF 6 name)" }, + { "ccittfax4", COMPRESSION_CCITTFAX4, "CCITT Group 4 fax encoding" }, + { "ccittt6", COMPRESSION_CCITT_T6, "CCITT T.6 (TIFF 6 name)" }, + { "lzw", COMPRESSION_LZW, "Lempel-Ziv & Welch" }, + { "ojpeg", COMPRESSION_OJPEG, "!6.0 JPEG" }, + { "jpeg", COMPRESSION_JPEG, "%JPEG DCT compression" }, + { "next", COMPRESSION_NEXT, "NeXT 2-bit RLE" }, + { "packbits", COMPRESSION_PACKBITS, "Macintosh RLE" }, + { "ccittrlew", COMPRESSION_CCITTRLEW, "CCITT modified Huffman RLE w/ word alignment" }, + { "deflate", COMPRESSION_DEFLATE, "Deflate compression" }, + { "adeflate", COMPRESSION_ADOBE_DEFLATE, "Deflate compression, as recognized by Adobe" }, + { "dcs", COMPRESSION_DCS, "Kodak DCS encoding" }, + { "jbig", COMPRESSION_JBIG, "ISO JBIG" }, + { "jp2000", COMPRESSION_JP2000, "Leadtools JPEG2000" }, + { NULL, 0, NULL } + }; + + f = NULL; + + // Set the compression + + compression = COMPRESSION_NONE; + + if (compressionStr == NULL || strcmp(compressionStr, "") == 0) { + compression = COMPRESSION_NONE; + } else { + int i; + for (i = 0; compressionList[i].compressionName != NULL; i++) { + if (strcmp(compressionStr, compressionList[i].compressionName) == 0) { + compression = compressionList[i].compressionCode; + break; + } + } + if (compressionList[i].compressionName == NULL) { + fprintf(stderr, "Unknown compression type '%.10s', using 'none'.\n", compressionStr); + fprintf(stderr, "Known compression types (the tiff library might not support every type)\n"); + for (i = 0; compressionList[i].compressionName != NULL; i++) { + fprintf(stderr, "%10s %s\n", compressionList[i].compressionName, compressionList[i].compressionDescription); + } + } + } + + // Set the bits per sample + + bitspersample = (mode == splashModeMono1? 1: 8); + + switch (mode) { + + case splashModeMono1: + case splashModeMono8: + samplesperpixel = 1; + photometric = PHOTOMETRIC_MINISBLACK; + break; + + case splashModeRGB8: + case splashModeBGR8: + samplesperpixel = 3; + photometric = PHOTOMETRIC_RGB; + break; + + default: + fprintf(stderr, "Mode %d not supported\n", mode); + return splashErrOpenFile; + } + + // Open the file + + if (openedFile == NULL) { + if (!fileName) { + return splashErrOpenFile; + } + f = TIFFOpen(fileName, "w"); + } else { + f = TIFFFdOpen(fileno(openedFile), (fileName? fileName: "-"), "w"); + } + + if (!f) { + return splashErrOpenFile; + } + + // Set more tags + + TIFFSetField(f, TIFFTAG_IMAGEWIDTH, width); + TIFFSetField(f, TIFFTAG_IMAGELENGTH, height); + TIFFSetField(f, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(f, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); + TIFFSetField(f, TIFFTAG_BITSPERSAMPLE, bitspersample); + TIFFSetField(f, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(f, TIFFTAG_PHOTOMETRIC, photometric); + TIFFSetField(f, TIFFTAG_COMPRESSION, (uint16) compression); + + bytesperline = samplesperpixel * width; + tiffLineLen = TIFFScanlineSize(f); + if (tiffLineLen < bytesperline) tiffLineLen = bytesperline; + tiffLine = (unsigned char *) _TIFFmalloc(tiffLineLen); + + if (!tiffLine) { + fprintf(stderr, "Could not allocate tiff line buffer of %d\n", tiffLineLen); + return splashErrOpenFile; + } + + TIFFSetField(f, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(f, rowsperstrip)); + TIFFSetField(f, TIFFTAG_XRESOLUTION, (double) hDPI); + TIFFSetField(f, TIFFTAG_YRESOLUTION, (double) vDPI); + TIFFSetField(f, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); + + // Write the image + + memset(tiffLine, '\0', tiffLineLen); + + switch (mode) { + + case splashModeMono1: + row = data; + for (y = 0; y < height; ++y) { + p = row; + tiffLinePtr = tiffLine; + for (x = 0; x < width; x += 8) { + *tiffLinePtr++ = *p++; + } + if (TIFFWriteScanline(f, tiffLine, y, 0) < 0) { + fprintf(stderr, "error writing tiff row %d\n", y); + break; + } + row += rowSize; + } + break; + + case splashModeMono8: + row = data; + for (y = 0; y < height; ++y) { + p = row; + for (x = 0; x < width; ++x) { + tiffLine[x] = *p; + ++p; + } + if (TIFFWriteScanline(f, tiffLine, y, 0) < 0) { + fprintf(stderr, "error writing tiff row %d\n", y); + break; + } + row += rowSize; + } + break; + + case splashModeRGB8: + row = data; + for (y = 0; y < height; ++y) { + p = row; + tiffLinePtr = tiffLine; + for (x = 0; x < width; ++x) { + *tiffLinePtr++ = splashRGB8R(p); + *tiffLinePtr++ = splashRGB8G(p); + *tiffLinePtr++ = splashRGB8B(p); + p += 3; + } + if (TIFFWriteScanline(f, tiffLine, y, 0) < 0) { + fprintf(stderr, "error writing tiff row %d\n", y); + break; + } + row += rowSize; + } + break; + + case splashModeBGR8: + row = data; + for (y = 0; y < height; ++y) { + p = row; + tiffLinePtr = tiffLine; + for (x = 0; x < width; ++x) { + *tiffLinePtr++ = splashBGR8R(p); + *tiffLinePtr++ = splashBGR8G(p); + *tiffLinePtr++ = splashBGR8B(p); + p += 3; + } + if (TIFFWriteScanline(f, tiffLine, y, 0) < 0) { + fprintf(stderr, "error writing tiff row %d\n", y); + break; + } + row += rowSize; + } + break; + } + + // Close the file + + TIFFClose(f); + + if (tiffLine) _TIFFfree(tiffLine); + + return splashOk; +} + +#endif --- poppler-0.15.2/splash/SplashBitmap.h- 2010-11-04 01:01:08.000000000 +0100 +++ poppler-0.15.2/splash/SplashBitmap.h 2010-11-28 20:15:53.088659649 +0100 @@ -69,6 +69,10 @@ SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI); SplashError writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI); +#if ENABLE_LIBTIFF + SplashError writeTIFFile(FILE *openedFile, char *fileName, double hDPI, double vDPI, const char *compressionStr); +#endif + void getPixel(int x, int y, SplashColorPtr pixel); Guchar getAlpha(int x, int y); --- poppler-0.15.2/utils/Makefile.am- 2010-10-17 17:16:50.000000000 +0200 +++ poppler-0.15.2/utils/Makefile.am 2010-11-28 21:23:46.834479697 +0100 @@ -22,6 +22,7 @@ LDADD = \ $(top_builddir)/poppler/libpoppler.la \ $(UTILS_LIBS) \ + $(LIBTIFF_LIBS) \ $(FONTCONFIG_LIBS) if BUILD_ABIWORD_OUTPUT --- poppler-0.15.2/utils/pdftoppm.cc- 2010-10-30 01:40:07.000000000 +0200 +++ poppler-0.15.2/utils/pdftoppm.cc 2010-11-28 20:14:02.486640524 +0100 @@ -53,6 +53,7 @@ static int lastPage = 0; static GBool printOnlyOdd = gFalse; static GBool printOnlyEven = gFalse; +static GBool singleFile = gFalse; static double resolution = 0.0; static double x_resolution = 150.0; static double y_resolution = 150.0; @@ -69,11 +70,13 @@ static GBool gray = gFalse; static GBool png = gFalse; static GBool jpeg = gFalse; +static GBool tiff = gFalse; static char enableFreeTypeStr[16] = ""; static char antialiasStr[16] = ""; static char vectorAntialiasStr[16] = ""; static char ownerPassword[33] = ""; static char userPassword[33] = ""; +static char TiffCompressionStr[16] = ""; static GBool quiet = gFalse; static GBool printVersion = gFalse; static GBool printHelp = gFalse; @@ -87,6 +90,8 @@ "print only odd pages"}, {"-e", argFlag, &printOnlyEven, 0, "print only even pages"}, + {"-singlefile", argFlag, &singleFile, 0, + "write only the first page and do not add digits"}, {"-r", argFP, &resolution, 0, "resolution, in DPI (default is 150)"}, @@ -126,6 +131,12 @@ {"-jpeg", argFlag, &jpeg, 0, "generate a JPEG file"}, #endif +#if ENABLE_LIBTIFF + {"-tiff", argFlag, &tiff, 0, + "generate a TIFF file"}, + {"-tiffcompression", argString, TiffCompressionStr, sizeof(TiffCompressionStr), + "set TIFF compression: none, packbits, jpeg, lzw, deflate"}, +#endif #if HAVE_FREETYPE_FREETYPE_H | HAVE_FREETYPE_H {"-freetype", argString, enableFreeTypeStr, sizeof(enableFreeTypeStr), "enable FreeType font rasterizer: yes, no"}, @@ -179,6 +190,10 @@ bitmap->writeImgFile(splashFormatPng, ppmFile, x_resolution, y_resolution); } else if (jpeg) { bitmap->writeImgFile(splashFormatJpeg, ppmFile, x_resolution, y_resolution); +#if ENABLE_LIBTIFF + } else if (tiff) { + bitmap->writeTIFFile(NULL, ppmFile, x_resolution, y_resolution, TiffCompressionStr); +#endif } else { bitmap->writePNMFile(ppmFile); } @@ -191,6 +206,10 @@ bitmap->writeImgFile(splashFormatPng, stdout, x_resolution, y_resolution); } else if (jpeg) { bitmap->writeImgFile(splashFormatJpeg, stdout, x_resolution, y_resolution); +#if ENABLE_LIBTIFF + } else if (tiff) { + bitmap->writeTIFFile(stdout, NULL, x_resolution, y_resolution, TiffCompressionStr); +#endif } else { bitmap->writePNMFile(stdout); } @@ -304,9 +323,20 @@ // get page range if (firstPage < 1) firstPage = 1; + if (singleFile && lastPage < 1) + lastPage = firstPage; if (lastPage < 1 || lastPage > doc->getNumPages()) lastPage = doc->getNumPages(); + if (singleFile && firstPage < lastPage) { + if (!quiet) { + fprintf(stderr, + "Warning: Single file will write only the first of the %d pages.\n", + lastPage + 1 - firstPage); + } + lastPage = firstPage; + } + // write PPM files paperColor[0] = 255; paperColor[1] = 255; @@ -348,9 +378,14 @@ pg_h = tmp; } if (ppmRoot != NULL) { - snprintf(ppmFile, PPM_FILE_SZ, "%.*s-%0*d.%s", - PPM_FILE_SZ - 32, ppmRoot, pg_num_len, pg, - png ? "png" : jpeg ? "jpg" : mono ? "pbm" : gray ? "pgm" : "ppm"); + const char *ext = png ? "png" : jpeg ? "jpg" : tiff ? "tiff" : mono ? "pbm" : gray ? "pgm" : "ppm"; + if (singleFile) { + snprintf(ppmFile, PPM_FILE_SZ, "%.*s.%s", + PPM_FILE_SZ - 32, ppmRoot, ext); + } else { + snprintf(ppmFile, PPM_FILE_SZ, "%.*s-%0*d.%s", + PPM_FILE_SZ - 32, ppmRoot, pg_num_len, pg, ext); + } savePageSlice(doc, splashOut, pg, x, y, w, h, pg_w, pg_h, ppmFile); } else { savePageSlice(doc, splashOut, pg, x, y, w, h, pg_w, pg_h, NULL);