Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ghostscript: how to decide the output resolution of converting a multi-page PDF to multiple TIFFs

I need to extract TIFF images from a bunch of multi-page PDF files from a scanner. During the scanning I specified a resolution of 600dpi.

  1. Here is the code I used to generate TIFF images:

    gs -q -dNOPAUSE -sDEVICE=tiffg4 \
       -sOutputFile=a_page%02d.tif a.pdf -r600x600 -c quit
    

    This gave me the correct number of TIFF images, however, the image dimension is smaller than I expected.

    No matter how I change the -r option, the output images have the same size.

    What happened here?

  2. The output TIFF images have some compression, how should I change the gs option so that they do NOT contain any compression?

    http://pages.cs.wisc.edu/~ghost/doc/cvs/Devices.htm#TIFF has a few options to select, but seems to me no one means "8-bit Black&White" + "Compression Free".

Does anybody how to solve these two problems?

like image 458
galactica Avatar asked Apr 22 '11 21:04

galactica


1 Answers

If you use tiffg4 for output, then you implicitely asked to also get the Fax G4 compression type in the PDF.

You can tell Ghostscript to use no compression by using a different TIFF output device, such as tiffgray (gray, 8bit), tiff24nc (RGB-TIFF, 8bit for each color channel), tiff32nc (CMYK-TIFF, 8bit for each color channel), .... All these output types are uncompressed by default.

You can also use tiffg4 but remove the compression:

gs \
 -o a_page%02d.tif \
 -sDEVICE=tiffg4 \
 -r600x600 \
 -g4960x7020 \
 -sCompression=none \
  a.pdf

BTW, there is no such thing as "8bit Black+White". There is "1bit Black+White", but as soon as you go beyond 1bit, you'll enter the realm of grayscales... :-)

like image 195
Kurt Pfeifle Avatar answered Oct 11 '22 01:10

Kurt Pfeifle