Page 1 of 1

PDF to jpeg, reducing text blurriness

Posted: 2011-07-03T04:50:38-07:00
by SnesleyWipes
I'm trying to automate creation of images from single-page PDFs, and am having trouble getting good-looking text in the output. The PDFs are mostly monochrome (but not always), and the output file needs to be 120dpi and at a fixed width with height varying according to the page size. My command-line currently looks roughly like this:

convert -density 600 input.pdf -resample 120 -resize 960x2000 output.jpg

If I've understood things correctly, this is setting IM to treat input.pdf as having a dpi of 600 (so that the input image is larger than the target output size), and then resizing and resampling at the same time for the output. Am I on the right track?

The text in the output images is invariably either too blurry, or too blocky. It seems obvious that I need to do some filtering, but I'm a bit lost with the maths fundamentals. I've fiddled about with point, triangle and gaussian filters, and with blur settings < 1.0, but I can't seem to find anything useful. Can anyone suggest some directions to pursue?

Thanks in advance!

Re: PDF to jpeg, reducing text blurriness

Posted: 2011-07-03T09:51:57-07:00
by whugemann
One cause for your problems is that you resize the raster image two times after having it generated from the vector source. The best thing to do would be to set the adequate density right at the start. If your pages are not all of the same size, this might need two intermediate steps in which you Convert the PDF to a test image and than Identify this.

Another improvement could be to choose a higher quality for the JPEG image by the -quality option, say "-quality 95%".

Re: PDF to jpeg, reducing text blurriness

Posted: 2011-07-03T11:52:57-07:00
by SnesleyWipes
whugemann wrote:If your pages are not all of the same size, this might need two intermediate steps in which you Convert the PDF to a test image and than Identify this.
They're all sorts of different sizes, unfortunately. Are you suggesting, to be clear, that I should (for instance) "convert -density 120 input.pdf temp.jpg", find out the dimensions of temp.jpg, and then use those to calculate the density for the real conversion? Interesting approach, if I've interpreted that correctly, and not one I'd have hit on myself - I'll investigate that and report back. Thanks!

Regarding jpeg compression, that's not an issue - I've been doing most of my testing into png, I just quoted jpeg because that's the desired end result and I didn't want to confuse matters. Sorry for the red herring!

Re: PDF to jpeg, reducing text blurriness

Posted: 2011-07-03T23:39:27-07:00
by whugemann
SnesleyWipes wrote:Are you suggesting, to be clear, that I should (for instance) "convert -density 120 input.pdf temp.jpg", find out the dimensions of temp.jpg, and then use those to calculate the density for the real conversion?
This is exactly what I meant.