Page 1 of 1

Quality of PNG converted from PDF

Posted: 2010-04-20T03:44:56-07:00
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

Re: Quality of PNG converted from PDF

Posted: 2010-04-20T04:50:09-07:00
by Bonzo
Try adding a density:

Code: Select all

convert -density 400 input.pdf output.png

Re: Quality of PNG converted from PDF

Posted: 2010-04-20T05:39:18-07:00
by ebgb
not sure that worked. it ticked away for a few minutes...

butt he resulting png cannot be parsed/opened

Re: Quality of PNG converted from PDF

Posted: 2010-04-20T05:45:11-07:00
by magick
The conversion completed for us without complaint. We're using ImageMagick 6.6.1-4 and Ghostscript 8.71.

Re: Quality of PNG converted from PDF

Posted: 2010-04-20T06:04:00-07:00
by ebgb
server screw up maybe, restarted Imagemagick (under ubuntu) and it now converts etc, but still blurry on the small print

Re: Quality of PNG converted from PDF

Posted: 2010-04-20T06:58:38-07:00
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.

Re: Quality of PNG converted from PDF

Posted: 2010-04-20T07:02:49-07:00
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!

Re: Quality of PNG converted from PDF

Posted: 2010-04-20T07:12:17-07:00
by magick
For the sharpest image you can supersample. For example,
  • convert -density 400 myimage.pdf -resize 25% myimage.png

Re: Quality of PNG converted from PDF

Posted: 2010-04-20T07:14:43-07:00
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

Re: Quality of PNG converted from PDF

Posted: 2015-10-22T14:15:23-07:00
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

Re: Quality of PNG converted from PDF

Posted: 2015-10-22T14:35:19-07:00
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