11

My stomach churns when I see this kind of output.

http://www.freeimagehosting.net/uploads/e1097a5a10.jpg

and this was my command as suggested by Best way to convert pdf files to tiff files

gswin32c.exe -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=a.tif a.pdf -c quit

What am I doing wrong?

(commercial products will not be considered)

Community
  • 1
  • 1
Setori
  • 10,326
  • 11
  • 40
  • 46

7 Answers7

15

tiffg4 is a black&white output device. You should use tiff24nc or tiff12nc as the output device colour PDFs - see ghostscript output devices. These will be uncompressed but you could put the resulting TIFFs through imagemagick or similar to resave as compressed TIFF.

danio
  • 8,548
  • 6
  • 47
  • 55
  • Thanks for the colour information. After including Philho's advice about resolution im finding my tif shooting up to 20+ megs. This is way beyond. Making use of imagemagick would reduce this? – Setori Oct 22 '08 at 01:35
  • Yes, ImageMagick (and many other image manipulation tools) can convert uncomressed TIFF to compressed TIFF. Are you sure you need TIFF? 24-bit PNG is a pretty good choice for screen capture. – Chris Dolan Oct 22 '08 at 03:45
  • must be tiff sadly, the whole backend system is setup for tiff, a change and the whole thing comes down kicking and screaming. Also i just found out it must be black and white... interfacing with legacy systems can be a little of a headache... pdf would be the best. – Setori Oct 22 '08 at 08:15
11

I have been using ImageMagick for quite a sometime. It's very nice tool with a lot of features.

Install ImageMagick and run following command. This is what I used on Linux, you may have to replace convert with the correct one.

Below command converts PDFs to CCITT Group 3 standard TIFs (Fax standard):

convert -define quantum:polarity=min-is-white \
        -endian MSB \
        -units PixelsPerInch \
        -density 204x196 \
        -monochrome \
        -compress Fax \
        -sample 1728 \
        "input.pdf" "output.tif"

Also you may use GraphicsMagick, it is also similar to ImageMagick, but ImageMagick more concerns with quality than speed.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Amil Waduwawara
  • 1,632
  • 1
  • 16
  • 14
  • This is by far the best option I have seen in a long time for converting a text based PDF to TIFF while maintaining decent quality and a low file size. Switching the compress option to Group4 reduces the file size even further, and I maybe seeing things, but it looks like the quality actually got even better. – Jim Walker Sep 14 '16 at 19:39
2

Like other posts suggested, use a color format (e.g. -sDEVICE=tiff24nc) and specify a higher resolution (e.g. -r600x600):

gswin32c.exe -q -dNOPAUSE -r600 -sDEVICE=tiff24nc -sOutputFile=a.tif a.pdf -c quit
  • 2
    Please do not add an answer when other posts already contain that answer. Instead, upvote the existing post which you agree with. – mah Nov 11 '12 at 15:38
1

It is quite nice for a fax! ;-)

danio's answer is probably the best, if you need a color copy.

I notice also, from the linked thread, that you omitted to specify DPI for the output, hence the bad look... If you need pure dithered B&W, you should use a higher resolution.

I also got a good looking image using NConvert

nconvert -page 1 -out tiff -dpi 200 -c 2 -o c.tif FMD.pdf

I mention it for the record, because I think you need a license to redistribute it (it is free for personal use otherwise).

PhiLho
  • 40,535
  • 6
  • 96
  • 134
1

Thanks guys this is what I ended up with

     os.popen(' '.join([
                       self._ghostscriptPath + 'gswin32c.exe', 
                       '-q',
                       '-dNOPAUSE',
                       '-dBATCH',
                       '-r800',
                       '-sDEVICE=tiffg4',
                       '-sPAPERSIZE=a4',
                       '-sOutputFile=%s %s' % (tifDest, pdfSource),
                       ]))
Setori
  • 10,326
  • 11
  • 40
  • 46
1

setori's command does not specify the resolution to use for the tiffg4 output. The consequence is: Ghostscript will use its default setting for that output, which is 204x196dpi.

In order to increase the resolution to 600dpi, add a -r600 commandline parameter:

gswin32c.exe ^
   -o output.tiff ^
   -sDEVICE=tiffg4 ^
   -r600 ^
    input.pdf

Also note that TIFFG4 is the standard fax format and as such it uses black+white/grayscale only, but no colors.

@jeff: Have you ever tried the -dDITHERPPI=<lpi> parameter with Ghostscript? (Reasonable values for lpi are N/5 to N/20, where N is the resolution in dpi. So for -r600 use try with -dDITHERPPI=30 to dDITHERPPI=120).

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
0

I ran into the same problem with fax pages.

I was using Imagick in php and this command fixed the way it looked.

$Imagick->blackThresholdImage('grey');

I didn't see any threshold option using 'gs' but convert may also work for you.

convert a.pdf -threshold 60% a.tif