![Image](https://i.stack.imgur.com/VEeOp.png)
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:
![Image](https://i.stack.imgur.com/nZhWo.png)
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;
}
}
}
The boss is more than happy to pay for help on fixing this.