可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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)
回答1:
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.
回答2:
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.
回答3:
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).
回答4:
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),
]))
回答5:
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
回答6:
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
).
回答7:
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