ImageMagick convert pdf to jpeg has poor text quality after upgrading ImageMagick version to 6.7.8

前端 未结 3 579
执念已碎
执念已碎 2020-12-13 00:19

After upgrading ImageMagick text quality got degraded when convert pdf to jpeg:

Old image

相关标签:
3条回答
  • 2020-12-13 01:00

    I see the same problem with your sample file. It looks like ImageMagick's delegates for the PDF conversion may have changed with the new install.

    If you try convert -verbose foo.pdf foo.jpeg, do you see -sDEVICE=pngalpha in the command that gets sent to gs? The pnmraw device has been used in the past, and switching back to that seems to fix the problem for me.

    In ImageMagick's delegates.xml file (which may be in /etc/ImageMagick, but could be somewhere else depending on your setup), look for the decode="ps:alpha" delegate line and change -sDEVICE=pngalpha in the command to -sDEVICE=pnmraw. (You can probably just search for pngalpha in the file.)

    0 讨论(0)
  • 2020-12-13 01:18

    PDF files are vector files and have no specific size. Their size is controlled by defining the density and units before reading in the PDF file. You can get better quality for the same desired output file size by supersampling. That means rasterize the PDF to a large size and then resize to your desired actual size. For example in ImageMagick:

    convert -units pixelsperinch -density 288 image.pdf -resize 25% output.jpg
    

    The nominal density if left off is 72 dpi. So 72*4=288. Then resize by 1/5=25% gets back to the same default size, but should look much better. Change the density or resize to deal with quality and final size as desired.

    0 讨论(0)
  • 2020-12-13 01:26

    it seem that problem at DPI. when convert pdf, imagemagick using Ghostscript. you can skip using imagemagick.

    $ gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dGridFitTT=2 -dUseCropBox -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r200x200 -sDEVICE=jpeg -dJPEGQ=100 -sOutputFile=foo-%05d.jpg foo.pdf
    

    set -r option higher value. Ghostscript have default value is 100DPI.

    or using convert option -density. this option set pdf converted DPI.

    $ convert -density 200x200 foo.pdf foo.jpg
    
    0 讨论(0)
提交回复
热议问题