Quality of PNG converted from PDF

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
ebgb
Posts: 11
Joined: 2010-03-24T15:04:01-07:00
Authentication code: 8675308

Quality of PNG converted from PDF

Post by ebgb »

tinkering away and am converting the pdf's to 8 bit png fine

one problem I am trying to work around. The original PDF's are mainly vector files, with some bitmap images in them. created originally in adobe illustrator

so, as vector files, if you were to zoom in to the original pdf all stays nice and sharp

when I convert the pdf to a png, the result is not so good. The pdf's are artwork files which people will view on line to approve, and much of the type becomes hard to read and a little blurred, have a look at the files:

opn original pdf in acrobat: http://ebgb.net/misc/foo.pdf

and then look at converted png: http://ebgb.net/misc/foo.png

I tried adding a '-resize 4000' into the command line, thinking that if the converted file was made bigger, it would keep the text sharp, but not so

Is there something I've missed in the convert process that will keep the type rendered nice and sharp. I'm guessing that there something going on with resolution here, the original PDF's are intended for print at 300dpi, so the conversion chops that down immediately to 72??

help!!

thanks
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Quality of PNG converted from PDF

Post by Bonzo »

Try adding a density:

Code: Select all

convert -density 400 input.pdf output.png
ebgb
Posts: 11
Joined: 2010-03-24T15:04:01-07:00
Authentication code: 8675308

Re: Quality of PNG converted from PDF

Post by ebgb »

not sure that worked. it ticked away for a few minutes...

butt he resulting png cannot be parsed/opened
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Quality of PNG converted from PDF

Post by magick »

The conversion completed for us without complaint. We're using ImageMagick 6.6.1-4 and Ghostscript 8.71.
ebgb
Posts: 11
Joined: 2010-03-24T15:04:01-07:00
Authentication code: 8675308

Re: Quality of PNG converted from PDF

Post by ebgb »

server screw up maybe, restarted Imagemagick (under ubuntu) and it now converts etc, but still blurry on the small print
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Quality of PNG converted from PDF

Post by magick »

PDF is rendered with Ghostscript. Quality issues should be posted to their development team. You may get improved color by adding -colorspace rgb before your PDF image filename on the command line or use a CMYK and sRGB color profile.
ebgb
Posts: 11
Joined: 2010-03-24T15:04:01-07:00
Authentication code: 8675308

Re: Quality of PNG converted from PDF

Post by ebgb »

think I've sorted it now!

quite an odd one, and no idea why it now works (or why I wrote the original line the way I did

originally I'd put

convert -resize $strPDF '4000' -density 400 /var/www/appro_png/$outputFile

ie the input file ($strPDF), then the settings then the output file (/var/www/appro_png/$outputFile), changed it to:

convert -resize '4000' -density 400 $strPDF /var/www/appro_png/$outputFile

and it nice and sharp now. thanks for the help though!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Quality of PNG converted from PDF

Post by magick »

For the sharpest image you can supersample. For example,
  • convert -density 400 myimage.pdf -resize 25% myimage.png
ebgb
Posts: 11
Joined: 2010-03-24T15:04:01-07:00
Authentication code: 8675308

Re: Quality of PNG converted from PDF

Post by ebgb »

I am going to have a play with that now, need to get a good image, but also find which is the quickest process time. this will all be happening in a browser from users files so need it to be as quick as possible and if I can create some sort of progress bar mechanism too
efa
Posts: 8
Joined: 2012-04-27T06:18:57-07:00
Authentication code: 13

Re: Quality of PNG converted from PDF

Post by efa »

normally I extract the embedded image with 'pdfimages' at the native resolution, then use IM's convert to the needed format:

Code: Select all

$ pdfimages -list fileName.pdf
$ pdfimages fileName.pdf fileName   # save in .ppm format
$ convert fileName-000.ppm fileName-000.png
this generate the best and smallest result file.

For lossy JPG embedded images, you had to use -j:

Code: Select all

$ pdfimages -j fileName.pdf fileName   # save in .jpg format
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Quality of PNG converted from PDF

Post by fmw42 »

magick wrote:For the sharpest image you can supersample. For example,
  • convert -density 400 myimage.pdf -resize 25% myimage.png
Actually, assuming the pdf has no density, which means a default of 72 dpi, the command should probably be 72*4=288 and 25% or

Code: Select all

convert -density 288 myimage.pdf -resize 25% myimage.png
unless you want to expand the image size in the resulting image
Post Reply