[英]Convert ImageMagick Command to PHP
我试图将以下命令更改为PHP,但我不知道该如何实现。 有人可以提出建议吗?
convert demo.jpg remove_background.jpg \
-compose difference -composite -separate \
-evaluate-sequence max -auto-level -negate \
match_alpha.png
convert -brightness-contrast 10x10 match_alpha.png output.png
我找到了一个很好的解决方案来执行PHP中的命令:
function execute($command)
{
# remove newlines and convert single quotes to double to prevent errors
$command = str_replace(array("\n", "'"), array('', '"'), $command);
# replace multiple spaces with one
$command = preg_replace('#(\s){2,}#is', ' ', $command);
# escape shell metacharacters
$command = escapeshellcmd($command);
# execute convert program
return shell_exec($command); // or whatever you like
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.