Hi all
I have a variety of scanned PDFs that are black and white like the following
Many thanks from a massive newbie
Grayscale matters
-
- Posts: 3
- Joined: 2013-02-02T19:04:12-07:00
- Authentication code: 6789
Grayscale matters
Last edited by visionhappens on 2013-02-02T19:48:53-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Colorizing scanned grayscale PDF
You do not say what resulting image format you want? If you process to pdf, IM will rasterize and then convert that to PDF.
because you want to keep the antialiasing of the text, you should try
convert test.pdf +level-colors red,white result.png (or gif or jpg)
see
http://www.imagemagick.org/Usage/color_ ... vel-colors
http://www.imagemagick.org/Usage/formats/#vector
because you want to keep the antialiasing of the text, you should try
convert test.pdf +level-colors red,white result.png (or gif or jpg)
see
http://www.imagemagick.org/Usage/color_ ... vel-colors
http://www.imagemagick.org/Usage/formats/#vector
-
- Posts: 3
- Joined: 2013-02-02T19:04:12-07:00
- Authentication code: 6789
Re: Colorizing scanned grayscale PDF
Thanks very much sir.fmw42 wrote:You do not say what resulting image format you want? If you process to pdf, IM will rasterize and then convert that to PDF.
because you want to keep the antialiasing of the text, you should try
convert test.pdf +level-colors red,white result.png (or gif or jpg)
see
http://www.imagemagick.org/Usage/color_ ... vel-colors
http://www.imagemagick.org/Usage/formats/#vector
Indeed ideally output would be pdf again. Just tried your suggestion and the resulting document is awfully small so text can't be read. Any suggestions how to recoup a clear readable document very welcome.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Colorizing scanned grayscale PDF
For example, green text on a white background:
I've shown it as three stages, but you could combine them into one.
Code: Select all
convert -density 150 test.pdf lecture2.png
convert lecture2.png -alpha Copy -fuzz 100% -fill White -opaque Gray -background Green -alpha Remove lecture3.png
convert lecture3.png lecture3.pdf
snibgo's IM pages: im.snibgo.com
-
- Posts: 3
- Joined: 2013-02-02T19:04:12-07:00
- Authentication code: 6789
Re: Colorizing scanned grayscale PDF
This is splendid thank you so much!snibgo wrote:For example, green text on a white background:I've shown it as three stages, but you could combine them into one.Code: Select all
convert -density 150 test.pdf lecture2.png convert lecture2.png -alpha Copy -fuzz 100% -fill White -opaque Gray -background Green -alpha Remove lecture3.png convert lecture3.png lecture3.pdf
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Colorizing scanned grayscale PDF
I cross-posted with fmw42. His "+level colors" is far more elegant, and probably quicker, than my version that messes around with alpha. My "-density 150" is what you need for readable text.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Colorizing scanned grayscale PDF
Since you are starting with PDF which is vector, it has no size. You have to specify the density you want in dpi. You probably need to use supersampling to increase the quality and then resize to the same input size (assuming it is 72 dpi nominally). What I usually do is
convert -density 288 test.pdf +level-colors red,white -resize 25% result
where 72*4=288 and 1/4=25%
But note that your output will be a raster image imbedded in a vector wrapper.
If you want a larger output size change the -resize argument to a larger value or just remove the -resize and adjust the -density to a value that gives you the size output in pixels that you want.
convert -density 288 test.pdf +level-colors red,white -resize 25% result
where 72*4=288 and 1/4=25%
But note that your output will be a raster image imbedded in a vector wrapper.
If you want a larger output size change the -resize argument to a larger value or just remove the -resize and adjust the -density to a value that gives you the size output in pixels that you want.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Grayscale matters
For PDFs that are a single raster image in a vector wrapper, as this one is, I open it in Adobe Reader and control-C the image, which copies it to the clipboard. Then ...
... tells me how many pixels it has.
Then I try a simple convert (at 72 ppi)...
... and arithmetic tells me the most obvious density to use (usually rounded to the nearest multiple of 150).
(This is in Windows7.)
Code: Select all
convert clipboard: info:
Then I try a simple convert (at 72 ppi)...
Code: Select all
convert test.pdf info:
(This is in Windows7.)
snibgo's IM pages: im.snibgo.com