[英]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.