docs:pdf:tiff_workflow

tiff workflow

  • scan methods
  • lighten/darken pages
  • erase borders, areas, or despeckle
  • density defines resolution of output image
  • units should be given, or else the file units will be undefined, and programs such as GraphicConverter will make the file 72dpi, which will cause conversion problems
  • page defines the canvas size, and will crop the image as necessary
  • examples:
    # full color example
    convert -density 150 -units PixelsPerInch -page letter SN-085.pdf SN-085.tif
    
    # monochrome, small size, similar to multi page tiff (fax) sheets
    convert -density 300 -units PixelsPerInch -page letter -monochrome -compress Group4 SN-085.pdf SN-085.tif
    
    # convert color pdf from Illustrator to small grayscale 8 bit tif w/small file size, adjusting contrast to make it darker
    convert.exe -density 200 -units PixelsPerInch -page letter -colorspace gray -compress lzw -alpha off -depth 8 -contrast-stretch .15%x60% input.pdf output.tif
  • requires Ghostscript (seems slower than imagemagick method, although imagemagick uses gs with the pnmraw output device)
  • -q = quiet mode
  • -dNOPAUSE = don't pause and ask questions after each page
  • -r = custom resolution
  • -sPAPERSIZE will force the output to be a proper papersize - this actually crops the page to this size which works well when the page is larger than represented and contains crop information
  • example:
    gs -q -dNOPAUSE -sDEVICE=tiff24nc -r150 -sPAPERSIZE=letter -sOutputFile=a.tif a.pdf -c quit
  • requires libtiff
tiffsplit input.tif
  • edit individual files (each page should be a file) as necessary using any graphics program, such as Adobe Photoshop, GraphicConverter etc… (GraphicConverter can edit multi-page tiff files, and keep them intact, although it changes the resolution to 72dpi so you need to run the convert -density command again to fix the file)
  • since individual tiff files are not the final work product, it would be best to not use compression, since some tools do not work well with certain compression schemes
  • when things turn pink…
    • There are versions of libtiff which improperly embed color lines in pdf files, causing pink and green pages. The best fix is to update or rebuild your libtiff tools/libraries. Sometimes your only option may be to go to a prior version of libtiff, which may solve the problem as well. 3.7.2 is confirmed as working properly.
    • You may end up with output of pink or green pages when using jpeg compression. Again, the best way to fix this is to update libtiff, but the following works for existing files:
      (the r forces JPEG encoded RGB)
      tiffcp -c jpeg:r:60 1.tif 1a.tif
      tiff2pdf -j -q60 1a.tif > 1.pdf
    • see also: http://www.nabble.com/Pink-pages-with-tiff2pdf--j-td13046770.html
      It looks like editing each PDF file in a text editor and changing
      
      ColorTransform 0
      
      to
      
      ColorTransform 1
      
      makes my PDF files display correctly, regardless of the viewing
      application I use.  So far I've tested this with acroread, kpdf and
      ghostscript with good results.  This change should be easy enough to
      do with sed. 
  • requires libtiff
    • single file (no compression):
      tiff2pdf -p letter -o output.pdf input.pdf
    • single file (zip compression):
      tiff2pdf -z -p letter -o output.pdf input.pdf
    • single file (jpeg compression, 60% quality):
      tiff2pdf -j -q60 -p letter -o output.pdf input.pdf
    • single file (zip compression, with document metadata):
      tiff2pdf -z -p letter -cprogramname -aauthorname -tdocumenttitle -sdocumentsubject -o output.pdf input.pdf
    • multiple files:
      ls -1L *.tif | while read file;do
      tiff2pdf -p letter -o "${file}".pdf "${file}"
      done
  • requires Ghostscript
    • tiff2ps -2 a.tif | gs -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=a.pdf - -c quit
  • requires libtiff
    tiffutil -cat x*.tif -out test.tif
    • this example uses the -c flag, which is set to lzw compression for much smaller files
      tiffcp -c lzw x*.tif output2.tif
  • requires imagemagick command line tools
    convert -adjoin x*.tif output.tif
  • requires pdftk
  • this example does not include compression, so with uncompressed tif images, the file size is very large
pdftk *.pdf cat output combined.pdf
  • requires libtiff
    • compress file using lzw compression:
      tiffcp -c lzw input.tif output.tif
    • convert to grayscale, and use lzw compression:
      tiff2bw -c lzw input.tif output.tif
    • compress file using CCITT Group 4 compression:(The CCITT Group 3 and Group 4 compression algorithms can only be used with bilevel data - 1 bit black and white images)
      tiffcp -c g4 input.tif output.tif
    • convert to 1-bit, using CCITT Group 4 compression (black and white)
      convert -monochrome -compress Groupt4 input.tif output.tif
    • convert to 1-bit (black and white) specifying threshold for black:
      convert -monochrome -black-threshold 35768 input.tif output.tif
  • convert a bunch of files into monochrome 1-bit images, with CCITT Group 4 compression, then combine them into one multipage tiff file, and finally convert them into one pdf file using zip compression:
    ls -1L x*.tif|while read file; do convert -monochrome -compress Group4 "${file}" "${file}".bw.tif; done
    
    tiffutil -cat *.bw.tif -out tifoutput.tif
    
    tiff2pdf -z -p letter -o output.pdf tifoutput.tif
  • docs/pdf/tiff_workflow.txt
  • Last modified: 2014/03/03 11:29
  • by billh