Page 1 of 1

converting a grayscale multipage PDF file to BW

Posted: 2010-07-02T17:29:59-07:00
by mark.farnell
I have a grayscale PDF file of music score, but this file does not have images, so it is really meant to be black and white. How can I convert this file to black and white to save space? Also how can I specify the filter cutoff point between white and black? I tried in ghostscript, but results is unsatisfactory. ghostscript seems to congretate a few neighbouring gray pixels to one black pixel - so light gray areas become spotted with black dots, whereas I want these light gray background areas completely *removed*

gs -sDEVICE=tiffg4 -sOutputFile=output.tiff input.pdf

Thanks!

Mark

Re: converting a grayscale multipage PDF file to BW

Posted: 2010-07-02T18:00:52-07:00
by fmw42
try supersampling and thresholding

convert -density 288 image.pdf -resize 25% -threshold 50% -type bilevel image.tiff

You can vary the threshold and see what value gives you the best results.

using -density 288=72*4 is 4 times higher resolution than nominal 72 dpi, so afterwards one resizes by 1/4=25%

You can resize by a larger percent if you want to have higher resolution, but the image will be bigger.

Re: converting a grayscale multipage PDF file to BW

Posted: 2010-07-02T18:50:46-07:00
by magick
To generate monochrome PDF's, try this command:

convert -monochrome page.pdf page.tiff

Re: converting a grayscale multipage PDF file to BW

Posted: 2010-07-02T19:24:52-07:00
by fmw42
see http://www.imagemagick.org/Usage/quantize/#monochrome about monochrome, but according to Anthony's page +dither has no effect on -monochrome, so that your results will be dithered. That was why I did not suggest it earlier. However, it is the simplest way to get b/w images and may suffice for you.

Re: converting a grayscale multipage PDF file to BW

Posted: 2010-07-03T00:25:14-07:00
by mark.farnell
I tried:

convert -monochrome page.pdf page.tiff

but like the gs command I used, it just pools surrounding light pixels (in light background) into a black pixel in monochrome, which wastes both disk space and toner.

What I really want is use threshold to distinguish between background and text, that's all.

Then I also tried:

convert -density 288 image.pdf -resize 25% -threshold 50% -type bilevel image.tiff
tiff2pdf image.tiff > output.pdf

However the pages of the resultant output.pdf become really small!

Re: converting a grayscale multipage PDF file to BW

Posted: 2010-07-03T05:33:54-07:00
by Drarakel
Replace '-resize 25%' with '-resample 72' (a quarter of 288). Then the printing size (if that's what you meant) should be preserved.