Page 1 of 1

yii imagemagick php5.4 to php7

Posted: 2016-10-06T05:42:10-07:00
by ross77
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" Image

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

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.

Re: yii imagemagick php5.4 to php7

Posted: 2016-10-06T07:29:01-07:00
by snibgo
What version of IM are you using? (And what version were you using, before the upgrade?)

To diagnose the problem, we need to reproduce it. Please provide example(s) for $this->cmd_image and $params['pattern'] and $params['color_code'].

Re: yii imagemagick php5.4 to php7

Posted: 2016-10-06T08:31:46-07:00
by ross77
Hi,
We're using ImageMagick 7.0.2-7 Q16 x86_64 2016-08-08 apparently.

I'll try to get them - this php carry on isn't my expertise ;-)

Give me 5. Thanks.

Re: yii imagemagick php5.4 to php7

Posted: 2016-10-06T08:42:32-07:00
by fmw42
I have moved this topic to the Users forum, since there was no mention of PAID consulting.

Re: yii imagemagick php5.4 to php7

Posted: 2016-10-06T08:50:45-07:00
by ross77
Apart from this line:

The boss is more than happy to pay for help on fixing this.

Re: yii imagemagick php5.4 to php7

Posted: 2016-10-06T08:55:04-07:00
by fmw42
I have moved it back to Consulting

Re: yii imagemagick php5.4 to php7

Posted: 2016-10-06T08:58:58-07:00
by fmw42
It would be most helpful if you could provide an example input image (the same as above) and your exact commands with values substituted for your arguments. It is very hard to follow and reproduce from code with argument in it, not knowing what those arguments mean or the range of values. So please make a simple example to demonstrate the problem.

Can you reproduce the problem outside of PHP, that is just a simple IM command line run from the terminal?

Re: yii imagemagick php5.4 to php7

Posted: 2016-10-06T09:34:40-07:00
by ross77
Hi,

Thanks for the reply. I've uploaded an example image here: https://i.stack.imgur.com/a4ndh.png

You'll have to bear with me on the other questions - I have to reply on someone else getting this info for me. I will post the answers as soon as I get them.

Thanks again.