dsykx64220
2017-03-06 11:12
浏览 57
已采纳

PHP - 使用Imagick将EPS转换为PNG


I am trying to convert eps to png image using imagick.This is the code i am using.



     $path = getcwd().'/uploads/1488/791/586/imprint_option_1A.eps';
        $save_path = getcwd().'/uploads/1488/791/586/imprint_option_2E_c.png';
        $image = new Imagick();
        $image->readimage($path);
        $image->setBackgroundColor(new ImagickPixel('transparent'));
        $image->setResolution(300,300);
        $image->scaleImage(600, 270);
        $image->setImageFormat("png");
        $image->writeImage($save_path);

but the transparency is not working i got image with white background ( Result image ). and when we scale image it loses clarity..

Any idea ?

Here is my eps file https://drive.google.com/open?id=0Bwq4DvGGbHVfT0FYTE94WW5GTnc

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douyan1970 2017-03-06 14:30
    已采纳

    The function setResolution should be called before reading the image. Thus

     $image = new Imagick();
     $image->setResolution(1200, 1200);
     $image->readImage($path);
    

    should do it. As for the transparency, can you try to get the input as sRGB instead of CMYK? If I convert first the input file to pdf with epstopdf and then use this converted file in the PHP script, it produces a transparent PNG file.

    点赞 打赏 评论

相关推荐 更多相似问题