我试图将以下命令更改为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
答案 0 :(得分:0)
我找到了一个很好的解决方案来执行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
}