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 求指导ADS低噪放设计
  • ¥15 CARSIM前车变道设置
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存