I have tried to change the following command(s) to PHP but I don´t know how I can achieve this. Can anyone make a suggestion?
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
I have found a nice solution to exec the commands in 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
}
According to https://stackoverflow.com/a/12061367/1648370
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.