简体   繁体   English

php imagick反走样

[英]Php imagick anti aliasing

I have a problem with my php: when I make conversion PDF to JPG not shown correctly. 我的php有问题:当我将PDF转换为JPG无法正确显示。

This is the original pictures of pdf - > http://s16.postimg.org/ma0jizgt1/text_problem2_fw.png 这是pdf的原始图片-> http://s16.postimg.org/ma0jizgt1/text_problem2_fw.png

This is the jpg after converting with imagick - > http://s14.postimg.org/ilhs9tt3l/text_problem_fw.png 这是用imagick转换后的jpg-> http://s14.postimg.org/ilhs9tt3l/text_problem_fw.png

Please can you help me ? 请你能帮我吗?

Thank you 谢谢

PHP: PHP:

if (move_uploaded_file( $_FILES["files"]["tmp_name"], $uploadUrlPdf . $_FILES["files"]["name"]))
{

    $_FILES['files']['name'];
    $nr_pag = $_POST['nr_pagini'];

    for($i = 0; $i < $nr_pag; $i++)
    {

        $fn = $uploadUrlSwf.sprintf("%02d", "$i").".jpg";

        if (!file_exists($fn)) 
        {
            $im = new imagick();

            $im->setResolution($dpi,$dpi);
            $pdf = $uploadUrlPdf.$_FILES['files']['name']."[$i]";
            $im->readimage($pdf); 

            $im->setImageFormat('jpg');
            $im->writeImage($fn);
            file_put_contents( $fn, (string)$im );
            $im->clear(); 
            $im->destroy();
        }

    }
}
else
{     
    echo "error!";
}

Try setting your dpi value higher. 尝试将dpi值设置得更高。 If that does not work, try another export format (other than jpg). 如果不起作用,请尝试其他导出格式(jpg以外)。 SVG would be your best bet, because you can scale that while the text and other shapes are still perfect quality. SVG将是您最好的选择,因为您可以在文本和其他形状仍然是完美质量的同时进行缩放。 JPG wil not be sharp at a high zoom level if the resolution (dpi) is too low. 如果分辨率(dpi)太低,则JPG在高缩放级别上将不清晰。

This forum entry might help: anti-aliased text when exporting PDF to image 该论坛条目可能会帮助: 将PDF导出到图像时消除锯齿的文本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM