douben1891 2012-11-26 20:29
浏览 67
已采纳

从转换命令转移到ImageMagick的直接PHP

I am moving to a new hosting company that will not allow me to exec a convert command for ImageMagick. So I now have to attempt to do it through straight PHP. I have spent quite a bit of time trying to figure it out and every where that I look, people recommend using the convert command like I am. I would appreciate any help or guidance in writing the following commands in straight PHP.

# Applies overlay $filter_image to the original $image
convert $image ( -clone 0 -alpha off $filter_image -compose SoftLight -composite ) -compose SrcIn -composite $output_image

and

# Apply a blur to an image
convert $image -blur 0x$blur_radius $output_image

UPDATE:

I have figured out the syntax and posted it as an answer.

  • 写回答

2条回答 默认 最新

  • douwei3280 2012-11-27 00:54
    关注

    I finally figured it out on my own. Here is the solution in case anyone else runs into this.

    Blur an image...

    $imagick = new Imagick($image);
    $imagick->blurImage(0,$blur_radius);
    $imagick->writeImage($output_image);
    

    Add an overlay to an image...

    $imagick = new Imagick($image);
    $overlay = new Imagick($filter_image);
    
    $imagick->compositeImage($overlay, imagick::COMPOSITE_SOFTLIGHT, 0, 0);
    $imagick->writeImage($output_image);
    

    You can easily combine the two methods as well and blur the image and then add a composite overlay to it.

    $imagick = new Imagick($image);
    $imagick->blurImage(0,$blur_radius);
    
    $overlay = new Imagick($filter_image);
    $imagick->compositeImage($overlay, imagick::COMPOSITE_SOFTLIGHT, 0, 0);
    
    $imagick->writeImage($output_image);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决