Text antialiasing, poor file conversion

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
youds
Posts: 53
Joined: 2010-01-28T05:38:11-07:00
Authentication code: 8675309

Text antialiasing, poor file conversion

Post by youds »

Hi

I'm trying to convert a high res PDF file to JPG file, and am noticing that there is no text anti aliasing. See link below.
http://www.imagemagick.org/script/comma ... #antialias

When I run "convert file.pdf file.jpg" and "convert -antialias file.pdf file.jpg" there is no difference between the two files.
Files can be seen in the "imagick" folder here: http://public.me.com/craigfairhurst

How do you turn antialias'ing on? Use a blur perhaps? The text quality is visibly poor in the resulting file, see "imagick" folder above.
ImageMagick 6.5.9-1
GhostScript 8.7
libpng-1.2.43RC1
iMagick 3.0.0RC1
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Text antialiasing, poor file conversion

Post by fmw42 »

use supersampling

convert -density 288 image.pdf -resize 25% image.jpg

density 288=4*72 where 72 is nominal density so resize down by 1/4=25%
youds
Posts: 53
Joined: 2010-01-28T05:38:11-07:00
Authentication code: 8675309

Re: Text antialiasing, poor file conversion

Post by youds »

Excellent, thanks.
ImageMagick 6.5.9-1
GhostScript 8.7
libpng-1.2.43RC1
iMagick 3.0.0RC1
youds
Posts: 53
Joined: 2010-01-28T05:38:11-07:00
Authentication code: 8675309

Re: Text antialiasing, poor file conversion

Post by youds »

Hi

Could do with revisiting this. I've been working with this project since the start of the year and have progressed quite a way with converting between postscript-type files, namely PDFs.
I've already deployed a solution with ImageMagick that outputs JPG's in high quality format from PDF's.
I've noticed however that there are significant differences in the rendering of text compared to images. Images render fine, texts degrade much quicker at lower densities.

I'm aware that the rasterization takes place which is where the problem fundamentally lies, however is there anything more that can be done to make it more smooth for text when being processed? I've noticed particularly at lower densities eg. 92 the text is worse than the images.

Any help would be appreciated.
ImageMagick 6.5.9-1
GhostScript 8.7
libpng-1.2.43RC1
iMagick 3.0.0RC1
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Text antialiasing, poor file conversion

Post by Drarakel »

I don't think that there is an alternative to the supersampling method.
Ghostscript makes the rasterization. You can change the handling of the elements that are antialiased. But some things are simply not antialiased at all with Ghostscript. (I think that normal fonts are antialiased. But other vector graphics are not - or not always?)
youds
Posts: 53
Joined: 2010-01-28T05:38:11-07:00
Authentication code: 8675309

Re: Text antialiasing, poor file conversion

Post by youds »

Possibly yes. I've been looking for an alternative to manage the vector files and haven't come across anything suitable, GIMP on the command line was all that I came across.
ImageMagick 6.5.9-1
GhostScript 8.7
libpng-1.2.43RC1
iMagick 3.0.0RC1
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Text antialiasing, poor file conversion

Post by Drarakel »

But what hinders you from using the supersampling method? I think the only disadvantages are an increased processing time - and a bit of blurriness (if the upsampling/downsampling size is not ideal). But the jagged edges of the text will be gone.
If you have problems with specific PDFs, you could upload an example..
youds
Posts: 53
Joined: 2010-01-28T05:38:11-07:00
Authentication code: 8675309

Re: Text antialiasing, poor file conversion

Post by youds »

Filesize, mainly. Rasterization is an issue however not at low density due to PDFs being for email delivery.
See http://public.me.com/craigfairhurst (the enclosed ZIP file)
ImageMagick 6.5.9-1
GhostScript 8.7
libpng-1.2.43RC1
iMagick 3.0.0RC1
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Text antialiasing, poor file conversion

Post by Drarakel »

The filesize should stay about the same with supersampling.
Anyway, this method is mainly for vectorial elements that can be rasterized at a higher density and then get downsized (and the downsizing does some sort of antialiasing).

But this last PDF is solely made out of images (already rasterized, stored with a simple RLE compression) - with no (vectorial) text at all. The best thing you can do with such a PDF is to just 'rasterize' it again with the source density (105dpi in your case). You could probably test some things to reduce the jagged edges (blurring or something like that), but personally, I would stay with the unmodified source images. If you resize the 105dpi images to a lower resolution, the jagginess will also be a bit reduced of course.
Example - the 5th page at 105dpi:
http://i41.tinypic.com/5bol0.png
Then resampled to 72dpi:
http://i39.tinypic.com/29gbbf6.png
IMO, there's no automatic way to rasterize various PDFs - at least if you always want a 'perfect' result. :wink:
Post Reply