We've been using imagemagick in Yii for a couple of years to allow people to "decorate" a balloon online. Running on php5.4 this has always worked really well. Here's an example of one of the "balloons" balloon with working decorator We recently upgraded the website to run on php7 for a variety of reasons. Sadly this has meant imagemagick isn't working the way it used to. See this link for an example: balloon without working decorator I wont say it's broken because I don't believe it is. I think we need to tweak/update the code. The problem is even the guy who implemented this for us can't work it out. This is the problem in his words
First command extracts the non-transparent part of the image and the second colours it. According to my tests, the first command (-alpha extract) works perfectly, however the latter (-background COLOUR -alpha shape) does colour the whole image, not just the extracted part.
Here's the code we're trying to use (and has successfully worked on php5.4 for over two years):
public function color($params) {
if (isset($params['pattern'])) {
$error = exec(escapeshellcmd($this->dir . 'convert' . $this->ext) . ' ' . $this->cmd_image . ' -alpha extract ' . $this->cmd_image);
$error .= exec(escapeshellcmd($this->dir . 'convert' . $this->ext) . ' ' . $this->cmd_image . ' tile:' . $params['pattern'] . ' \ -compose Multiply -composite ' . $this->cmd_image);
$error .= exec(escapeshellcmd($this->dir . 'convert' . $this->ext) . ' ' . $this->cmd_image . ' -background \'' . $params['color_code'] . '\' -alpha shape ' . $this->cmd_image);
if (!$error) {
return TRUE;
} else {
return FALSE;
}
} else {
$error = exec(escapeshellcmd($this->dir . 'convert' . $this->ext) . ' ' . $this->cmd_image . ' -alpha extract ' . $this->cmd_image);
$error .= exec(escapeshellcmd($this->dir . 'convert' . $this->ext) . ' ' . $this->cmd_image . ' -background \'' . $params['color_code'] . '\' -alpha shape ' . $this->cmd_image);
if (!$error) {
return TRUE;
} else {
return FALSE;
}
}
}
Any and all suggestions as to what we're doing wrong in php7 gratefully received!
Thanks :)