PHP Imagick PDF conversion Text aliasing

前端 未结 2 401
[愿得一人]
[愿得一人] 2020-12-07 06:13

I\'m having some troubles converting PDF files to JPEG with Imagick in PHP. After a lot of research, i\'m able to convert CMYK pdf to RGB jpg without weird color conversion

相关标签:
2条回答
  • 2020-12-07 06:37

    Image Magick uses Ghostscript to actually render PDFs, and I think you are using a version of Ghostscript that has a bug in it, that causes text not to be anti-aliased correctly.

    I tested the code you provided, as well as with a direct invocation of Ghostscript with the command.

    gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=1 -sDEVICE=pngalpha -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r150  -sOutputFile=foo-%d.png flyer.pdf
    

    By default, my Centos box was using Ghostscript version 8.70 which shows the issue you're seeing, both when invoked from Imagick and from the gs command above. Downloading version 9.14 from here makes the text be anti-aliased correctly when using the command-line, and probably would when invoked via Imagick.

    0 讨论(0)
  • 2020-12-07 06:41

    It is not a problem with anti-aliasing most likely.

    Increase your resolution up to 400 and see what happens.

    $imagick->setResolution(400,400);
    
    0 讨论(0)
提交回复
热议问题