--- poppler-0.15.2/config.h.cmake- 2010-10-17 17:16:49.000000000 +0200 +++ poppler-0.15.2/config.h.cmake 2010-12-01 16:46:19.695402424 +0100 @@ -9,6 +9,9 @@ /* Use libopenjpeg instead of builtin jpeg2000 decoder. */ #cmakedefine ENABLE_LIBOPENJPEG 1 +/* Build against libtiff. */ +#cmakedefine ENABLE_LIBTIFF 1 + /* Build against libpng. */ #cmakedefine ENABLE_LIBPNG 1 --- 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/goo/Makefile.am- 2010-11-11 00:07:52.000000000 +0100 +++ poppler-0.15.2/goo/Makefile.am 2010-12-01 04:45:51.001733103 +0100 @@ -15,6 +15,7 @@ FixedPoint.h \ PNGWriter.h \ JpegWriter.h \ + TiffWriter.h \ ImgWriter.h \ GooLikely.h \ gstrtod.h @@ -40,5 +41,6 @@ FixedPoint.cc \ PNGWriter.cc \ JpegWriter.cc \ + TiffWriter.cc \ ImgWriter.cc \ gstrtod.cc --- poppler-0.15.2/goo/TiffWriter.cc- 2010-12-01 04:37:19.000059818 +0100 +++ poppler-0.15.2/goo/TiffWriter.cc 2010-12-01 19:08:34.699573871 +0100 @@ -0,0 +1,217 @@ +//======================================================================== +// +// TiffWriter.cc +// +// This file is licensed under the GPLv2 or later +// +// Copyright (C) 2010 William Bader +// +//======================================================================== + +#include "TiffWriter.h" + +#if ENABLE_LIBTIFF + +#include + +TiffWriter::~TiffWriter() +{ + // no cleanup needed +} + +TiffWriter::TiffWriter() +{ + f = NULL; + numRows = 0; + curRow = 0; + outputFileName = NULL; + compressionStr = NULL; + splashMode = splashModeRGB8; +} + +// Set the output file name + +void TiffWriter::setOutputFileName(const char *outputFileNameArg) +{ + outputFileName = outputFileNameArg; +} + +// Set the compression type + +void TiffWriter::setCompressionStr(const char *compressionStrArg) +{ + compressionStr = compressionStrArg; +} + +// Set the bitmap mode + +void TiffWriter::setSplashMode(enum SplashColorMode splashModeArg) +{ + splashMode = splashModeArg; +} + +// Write a TIFF file. +// If openedFile is not NULL, try to use it, otherwise open fileName + +bool TiffWriter::init(FILE *openedFile, int width, int height, int hDPI, int vDPI) +{ + int x, y; + unsigned int compression; + uint16 photometric; + uint32 rowsperstrip = (uint32) -1; + int bitspersample; + uint16 samplesperpixel; + static struct compression_name_tag { + const char *compressionName; // name of the compression option from the command line + unsigned int compressionCode; // internal libtiff code + const char *compressionDescription; // descriptive name + } 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 } + }; + + // Initialize + + f = NULL; + curRow = 0; + + // Store the number of rows + + numRows = height; + + // 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, "TiffWriter: 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 bits per sample, samples per pixel, and photometric type from the splash mode + + bitspersample = (splashMode == splashModeMono1? 1: 8); + + switch (splashMode) { + + case splashModeMono1: + case splashModeMono8: + samplesperpixel = 1; + photometric = PHOTOMETRIC_MINISBLACK; + break; + + case splashModeRGB8: + case splashModeBGR8: + samplesperpixel = 3; + photometric = PHOTOMETRIC_RGB; + break; + + default: + fprintf(stderr, "TiffWriter: Mode %d not supported\n", splashMode); + return false; + } + + // Open the file + + if (openedFile == NULL) { + if (!outputFileName) { + fprintf(stderr, "TiffWriter: No output file given.\n"); + return false; + } + f = TIFFOpen(outputFileName, "w"); + } else { + f = TIFFFdOpen(fileno(openedFile), (outputFileName? outputFileName: "-"), "w"); + } + + if (!f) { + return false; + } + + // Set TIFF 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); + 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); + + return true; +} + +bool TiffWriter::writePointers(unsigned char **rowPointers, int rowCount) +{ + // Write all rows to the file + + int row; + + for (row = 0; row < rowCount; row++) { + if (TIFFWriteScanline(f, rowPointers[row], row, 0) < 0) { + fprintf(stderr, "TiffWriter: Error writing tiff row %d\n", row); + return false; + } + } + + return true; +} + +bool TiffWriter::writeRow(unsigned char **rowData) +{ + // Add a single row + + if (TIFFWriteScanline(f, *rowData, curRow, 0) < 0) { + fprintf(stderr, "TiffWriter: Error writing tiff row %d\n", curRow); + return false; + } + + curRow++; + + return true; +} + +bool TiffWriter::close() +{ + // Close the file + + TIFFClose(f); + + return true; +} + +#endif --- poppler-0.15.2/goo/TiffWriter.h- 2010-12-01 04:37:19.000059818 +0100 +++ poppler-0.15.2/goo/TiffWriter.h 2010-12-01 15:51:45.300541124 +0100 @@ -0,0 +1,55 @@ +//======================================================================== +// +// TiffWriter.h +// +// This file is licensed under the GPLv2 or later +// +// Copyright (C) 2010 William Bader +// +//======================================================================== + +#ifndef TIFFWRITER_H +#define TIFFWRITER_H + +#include + +#ifdef ENABLE_LIBTIFF + +#include +#include "ImgWriter.h" +#include "splash/SplashTypes.h" + +extern "C" { +#include "tiffio.h" +} + +class TiffWriter : public ImgWriter +{ + public: + TiffWriter(); + ~TiffWriter(); + + void setOutputFileName(const char *outputFileNameArg); + void setCompressionStr(const char *compressionStr); + void setSplashMode(enum SplashColorMode splashModeArg); + + bool init(FILE *openedFile, int width, int height, int hDPI, int vDPI); + + bool writePointers(unsigned char **rowPointers, int rowCount); + bool writeRow(unsigned char **rowData); + + bool close(); + + private: + TIFF *f; // LibTiff file context + int numRows; // number of rows in the image + int curRow; // number of rows written + const char *outputFileName; // name of the output file + const char *compressionStr; // compression type + enum SplashColorMode splashMode; // format of image data + +}; + +#endif + +#endif --- 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-12-01 16:04:35.009684276 +0100 @@ -39,6 +39,7 @@ #include "poppler/Error.h" #include "goo/JpegWriter.h" #include "goo/PNGWriter.h" +#include "goo/TiffWriter.h" #include "goo/ImgWriter.h" //------------------------------------------------------------------------ @@ -274,7 +275,7 @@ return alpha[y * width + x]; } -SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI) { +SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, const char *compressionStr) { FILE *f; SplashError e; @@ -282,13 +283,13 @@ return splashErrOpenFile; } - e = writeImgFile(format, f, hDPI, vDPI); + e = writeImgFile(format, f, hDPI, vDPI, compressionStr); fclose(f); return e; } -SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI) { +SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, const char *compressionStr) { ImgWriter *writer; SplashError e; @@ -305,6 +306,16 @@ break; #endif + #ifdef ENABLE_LIBTIFF + case splashFormatTiff: + writer = new TiffWriter(); + if (writer) { + ((TiffWriter *)writer)->setCompressionStr(compressionStr); + ((TiffWriter *)writer)->setSplashMode(mode); + } + break; + #endif + default: // Not the greatest error message, but users of this function should // have already checked whether their desired format is compiled in. --- poppler-0.15.2/splash/SplashBitmap.h- 2010-11-04 01:01:08.000000000 +0100 +++ poppler-0.15.2/splash/SplashBitmap.h 2010-12-01 04:57:48.048883558 +0100 @@ -65,8 +65,8 @@ SplashError writePNMFile(char *fileName); SplashError writePNMFile(FILE *f); - SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI); - SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI); + SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, const char *compressionStr); + SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, const char *compressionStr); SplashError writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI); void getPixel(int x, int y, SplashColorPtr pixel); --- poppler-0.15.2/splash/SplashTypes.h- 2010-07-24 01:18:28.000000000 +0200 +++ poppler-0.15.2/splash/SplashTypes.h 2010-12-01 04:11:28.356547341 +0100 @@ -160,7 +160,8 @@ enum SplashImageFileFormat { splashFormatJpeg, - splashFormatPng + splashFormatPng, + splashFormatTiff }; #endif --- 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/pdftohtml.cc- 2010-11-08 21:45:24.000000000 +0100 +++ poppler-0.15.2/utils/pdftohtml.cc 2010-12-01 16:09:27.896018187 +0100 @@ -441,7 +441,7 @@ htmlFileName->getCString(), pg, extension); bitmap->writeImgFile(format, imgFileName->getCString(), - resolution, resolution); + resolution, resolution, ""); delete imgFileName; } --- poppler-0.15.2/utils/pdftoppm.1- 2010-10-17 17:16:50.000000000 +0200 +++ poppler-0.15.2/utils/pdftoppm.1 2010-12-01 21:37:13.707305884 +0100 @@ -83,6 +86,12 @@ .B \-jpeg Generates a JPEG file instead a PPM file. .TP +.B \-tiff +Generates a TIFF file instead a PPM file. +.TP +.BI \-tiffcompression " none | packbits | jpeg | lzw | deflate" +Specifies the TIFF compression type. This defaults to "none". +.TP .BI \-freetype " yes | no" Enable or disable FreeType (a TrueType / Type 1 font rasterizer). This defaults to "yes". --- poppler-0.15.2/utils/pdftoppm.cc- 2010-10-30 01:40:07.000000000 +0200 +++ poppler-0.15.2/utils/pdftoppm.cc 2010-12-01 16:20:45.083763878 +0100 @@ -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; @@ -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"}, @@ -176,9 +187,13 @@ if (ppmFile != NULL) { if (png) { - bitmap->writeImgFile(splashFormatPng, ppmFile, x_resolution, y_resolution); + bitmap->writeImgFile(splashFormatPng, ppmFile, x_resolution, y_resolution, ""); } else if (jpeg) { - bitmap->writeImgFile(splashFormatJpeg, ppmFile, x_resolution, y_resolution); + bitmap->writeImgFile(splashFormatJpeg, ppmFile, x_resolution, y_resolution, ""); +#if ENABLE_LIBTIFF + } else if (tiff) { + bitmap->writeImgFile(splashFormatTiff, ppmFile, x_resolution, y_resolution, TiffCompressionStr); +#endif } else { bitmap->writePNMFile(ppmFile); } @@ -188,9 +203,13 @@ #endif if (png) { - bitmap->writeImgFile(splashFormatPng, stdout, x_resolution, y_resolution); + bitmap->writeImgFile(splashFormatPng, stdout, x_resolution, y_resolution, ""); } else if (jpeg) { - bitmap->writeImgFile(splashFormatJpeg, stdout, x_resolution, y_resolution); + bitmap->writeImgFile(splashFormatJpeg, stdout, x_resolution, y_resolution, ""); +#if ENABLE_LIBTIFF + } else if (tiff) { + bitmap->writeImgFile(splashFormatTiff, stdout, x_resolution, y_resolution, TiffCompressionStr); +#endif } else { bitmap->writePNMFile(stdout); } @@ -348,9 +378,9 @@ 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 ? "tif" : mono ? "pbm" : gray ? "pgm" : "ppm"; + 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);