duanboshi1472
2019-08-14 03:58
浏览 204
已采纳

将Imagemagick命令转换为php imagick

I need to convert the ImageMagick Command to PHP Imagick. I have tried a few combinations but nothing worked as expected. The command creates a line with pointy edges and gradient at the edges The command is:

convert -size 300x1 xc:red \
\( -size 1x300 gradient: -rotate 90 -solarize 50% -level 0x50% -white-threshold 50% +write grad.png \) \
-alpha off -compose copy_opacity -composite red_grad.png`

thanks to @fmw42 for this command

I have tried the following code:

$line = new Imagick();
$line->newPseudoImage(300,1,'xc:red');
$shadow = new Imagick();
$shadow->newPseudoImage(1, 300, 'gradient:red-white');
$shadow->rotateImage('transparent', 90);
$shadow->solarizeImage(50);
$shadow->levelImage(0,50,50);
$shadow->whiteThresholdImage('white');
$shadow->setImageCompose(0);
$shadow->writeImage('grad.png');
$shadow->compositeImage($line, Imagick::COMPOSITE_MATHEMATICS, 0, 0);

Please point out where am I going wrong

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongtuoao7987 2019-08-14 23:56
    已采纳

    With a few tweaks, @fmw42 answer worked for me. The correct solution is given below

    $redline = new Imagick();
    $redline->newPseudoImage(1100,3,'xc:'.$chipColourPixel->getColorAsString());
    $grad = new Imagick();
    $grad->newPseudoImage(3, 900, 'gradient:black-white');
    $grad->rotateImage('white', 90);
    $grad->solarizeImage((int)ceil(50*Imagick::QUANTUM_RANGE/100));
    $grad->levelImage(0,1,50*Imagick::QUANTUM_RANGE/100);
    $redline->compositeImage($grad, Imagick::COMPOSITE_COPYOPACITY, 0, 0);
    $redline->writeImage("redline.png");
    
    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题