dongpo2014 2013-07-24 23:39
浏览 38
已采纳

ImageMagick小插图的黑色?

PHP Imagemagick API has a vignette function: http://www.php.net/manual/en/imagick.vignetteimage.php

Great, but how do I get it with black color?

  • 写回答

1条回答 默认 最新

  • dongpo5264 2013-07-25 13:35
    关注

    Vignette's will default to the given image's background color. Altering this color is as simple as setting the image's background color before transforming the image with the Vignette effect.

    <?php
    $img = new Imagick("source.png");
    
    $img->setImageBackgroundColor("black");
    $img->vignetteImage(-5.0,15.0,15,15);
    
    $img->writeImage("source_vignette.png");
    $img->destroy();
    exit();
    

    enter image description here

    Better yet. Use the ImagickPixel object for increased flexibility within your application.

    <?php
    $img = new Imagick("source.png");
    
    $pixel = new ImagickPixel();
    
    for($i=0;$i < 1; $i += 0.1) {
     $pixel->setHSL($i,0.5,0.5);
     $img->setImageBackgroundColor($pixel);
     $img->vignetteImage(-5.0,15.0,15,15);
     $img->writeImage("source_vignette_$i.png");
    }
    
    $pixel->destroy();
    $img->destroy();
    exit();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 CSS实现渐隐虚线框
  • ¥15 有没有帮写代码做实验仿真的
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题