代码之家  ›  专栏  ›  技术社区  ›  Cymro

imagick透明提示不工作

  •  0
  • Cymro  · 技术社区  · 8 年前

    我有一个图像:

    ![enter image description here

    我正在使用以下PHP/imagick代码:

    $BackgroundColor = "rgb(255, 255, 203)";
    $img = new Imagick();
    $img->readImage("xxxxxx");
    $img->setImageFormat('png'); 
    $img->transparentPaintImage($BackgroundColor,0,10,false);
    $img->writeImage("xxxxxxx");
    

    生成的图像不会将黄色更改为透明。 i、 e.如上图所示,图像保持黄色。

    任何建议都会被采纳。

    谢谢

    大卫

    1 回复  |  直到 8 年前
        1
  •  2
  •   emcconville    8 年前

    文件有点过时。您需要根据系统/库量程范围计算模糊百分比。

    $BackgroundColor = "rgb(255, 255, 203)";
    $img = new Imagick();
    $img->readImage("xxxxxx");
    $img->setImageFormat('png'); 
    $fuzz = Imagick::getQuantum() * 0.1; // 10%
    $img->transparentPaintImage($BackgroundColor,0,$fuzz,false);
    $img->writeImage("xxxxxxx");
    

    enter image description here