To lean against this question:
Imagick: Convert bash command into php script
I have a command that does exactly what I want to:
convert input.jpg -alpha set -bordercolor "rgb(255,255,255)"
-border 1 -fill none -fuzz 5% -draw "color 0,0 floodfill" -shave 1x1 out.png
So I tried to do the same thing in PHP Imagick.
$backgroundColor = $image->getImagePixelColor(0, 0);
$image->setImageAlphaChannel(\Imagick::ALPHACHANNEL_SET);
$image->borderImage($backgroundColor->getColorAsString(), 1, 1);
$image->floodFillPaintImage(
'transparent',
$fuzz * \Imagick::getQuantum(),
$backgroundColor->getColorAsString(),
0, 0,
false);
$image->shaveImage(1, 1);
I need this working in PHP not as a shell_exec()
command.
But the result of my PHP code is just a black image.
To test I use the image from phpimagick.com
image: https://phpimagick.com/imageOriginal/Tutorial/backgroundMasking
It is not necessary, that the inside of the chair is transparent too. I just need the background going away.
Some of you have any idea?
Thank you for your reply.