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

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制