PDF to jpeg, reducing text blurriness

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
SnesleyWipes
Posts: 2
Joined: 2011-07-03T04:21:38-07:00
Authentication code: 8675308

PDF to jpeg, reducing text blurriness

Post 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!
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: PDF to jpeg, reducing text blurriness

Post 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%".
Wolfgang Hugemann
SnesleyWipes
Posts: 2
Joined: 2011-07-03T04:21:38-07:00
Authentication code: 8675308

Re: PDF to jpeg, reducing text blurriness

Post 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!
User avatar
whugemann
Posts: 289
Joined: 2011-03-28T07:11:31-07:00
Authentication code: 8675308
Location: Münster, Germany 52°N,7.6°E

Re: PDF to jpeg, reducing text blurriness

Post 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.
Wolfgang Hugemann
Post Reply