Imagemagick PHP stopped working on update

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
iwantmedia
Posts: 22
Joined: 2016-05-21T14:59:43-07:00
Authentication code: 1151

Imagemagick PHP stopped working on update

Post by iwantmedia » 2016-05-21T15:05:45-07:00

Hi,

i am looking for some help. My hosting company (Heart internet) updated their php & imagemagick last week & now my script has partially stopped working.

My script takes either a pre-defined image or user uploaded image & then adds a picture frame with/without a mount to give an instant preview of a picture frame they can order.
The script is still working correctly by sizing the image, adding the mount board & then adds on the frame but it then doesn't overlay the set frame image and tile it around the edge.

Can anyone help? I've spent hours trying different things & google has no recent help either.

Thanks

User avatar
fmw42
Posts: 25376
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick PHP stopped working on update

Post by fmw42 » 2016-05-21T15:09:08-07:00

What do you get from

convert -version

Find where IM resides. Perhaps they have moved it and so it does not connect with PHP.

Are you using Imagemagick in PHP exec or Imagick API. Perhaps you were using Imagick and it did not get loaded with your ISPs reload or Imagick cannot find Imagemagick any longer.

iwantmedia
Posts: 22
Joined: 2016-05-21T14:59:43-07:00
Authentication code: 1151

Re: Imagemagick PHP stopped working on update

Post by iwantmedia » 2016-05-21T15:20:19-07:00

I am using PHP exec, imagemagic works because it reacts to the resize, borders etc commands when executed. It is failing to tile the chosen image around the edge.
See this link for an example: http://www.westendframes.co.uk/inc/crea ... 3863000495

It has added on a frame with 45° corners but it doesn't add the frames anymore.

Thanks
Tom

User avatar
fmw42
Posts: 25376
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick PHP stopped working on update

Post by fmw42 » 2016-05-21T15:26:17-07:00

Post the original images and your code using values not variables, so we can test your exact command. Also post the good and bad output.

Again what is your IM version and your platform?

convert -version

iwantmedia
Posts: 22
Joined: 2016-05-21T14:59:43-07:00
Authentication code: 1151

Re: Imagemagick PHP stopped working on update

Post by iwantmedia » 2016-05-21T15:47:26-07:00

When executing convert -version this is the result: Delegates (built-in): bzlib cairo djvu fontconfig freetype gslib jng jpeg ltdl openexr pangocairo png ps rsvg tiff wmf x xml zlib

For the script, the images it produces...
currently being produced: http://www.westendframes.co.uk/inc/crea ... 3870113648

This is what used to be produced: http://www.westendframes.co.uk/creations/example.jpg

Script:
exec("convert http://www.westendframes.co.uk/img/gall ... _220_8.jpg -write mpr:image +delete \ http://www.westendframes.co.uk/img/frame/045a-top.png -write mpr:edge_top +delete \ http://www.westendframes.co.uk/img/fram ... bottom.jpg -rotate 180 -write mpr:edge_btm +delete \ mpr:image -alpha set -bordercolor 'rgb(107,15,15)' -border 80 \ -compose Dst -frame 24x24+24 -compose over \ \ -transverse -tile mpr:edge_btm \ -draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \ -transverse -tile mpr:edge_top \ -draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \ mpr:image -gravity center -composite http://www.westendframes.co.uk/creations/123456.jpg);
Last edited by iwantmedia on 2016-05-21T16:06:58-07:00, edited 1 time in total.

User avatar
fmw42
Posts: 25376
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick PHP stopped working on update

Post by fmw42 » 2016-05-21T16:01:17-07:00

You still have not told me the exact IM version from

convert -version

Where are your source images? We cannot test your code without them!

iwantmedia
Posts: 22
Joined: 2016-05-21T14:59:43-07:00
Authentication code: 1151

Re: Imagemagick PHP stopped working on update

Post by iwantmedia » 2016-05-21T16:08:59-07:00

Answer modified above.

Script running: echo exec(convert -version);
Returns:
Delegates (built-in): bzlib cairo djvu fontconfig freetype gslib jng jpeg ltdl openexr pangocairo png ps rsvg tiff wmf x xml zlib

User avatar
fmw42
Posts: 25376
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick PHP stopped working on update

Post by fmw42 » 2016-05-21T16:15:30-07:00

Your output is missing the first few line:

convert -version

Version: ImageMagick 6.9.4-2 Q16 x86_64 2016-05-12 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib

User avatar
fmw42
Posts: 25376
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick PHP stopped working on update

Post by fmw42 » 2016-05-21T16:23:32-07:00

This works perfectly fine for me on IM 6.9.4.2 Q16 Mac OSX

Code: Select all

convert \( 3_Queens_Parade_300_x_220_8.jpg -write mpr:image +delete \) \
\( 045a-top.png -write mpr:edge_top +delete \) \
\( 045a-bottom.jpg -rotate 180 -write mpr:edge_btm +delete \) \
mpr:image -alpha set -bordercolor 'rgb(107,15,15)' -border 80 \
-compose Dst -frame 24x24+24 -compose over \
-transverse -tile mpr:edge_btm \
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
-transverse -tile mpr:edge_top \
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
mpr:image -gravity center -compose over -composite \
result.jpg

Try adding the parentheses and the final -compose over before -composite to be sure you reset the compose method back (from -compose Dst) to -compose over.

It is possible that it is just a bug in the version you updated to. That is why I wanted to know your exact IM version.

Try this:

Code: Select all

<?php
exec(convert -version",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
What do you get from:

Code: Select all

<?php
exec(type -a convert",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>
Do you have multiple versions of IM?

iwantmedia
Posts: 22
Joined: 2016-05-21T14:59:43-07:00
Authentication code: 1151

Re: Imagemagick PHP stopped working on update

Post by iwantmedia » 2016-05-21T16:40:52-07:00

I have just tried the changes you suggested and still get the same result.
IM version details...
Version: ImageMagick 6.9.3-9 Q16 x86_64 2016-05-04 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo djvu fontconfig freetype gslib jng jpeg ltdl openexr pangocairo png ps rsvg tiff wmf x xml zlib

User avatar
fmw42
Posts: 25376
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick PHP stopped working on update

Post by fmw42 » 2016-05-21T18:31:08-07:00

It works fine for me under IM 6.9.3.9 Q16 Mac OSX.

Try either recompiling without openmp or adding -limit thread 1 right after convert

convert -limit thread 1 ... rest of your code

User avatar
fmw42
Posts: 25376
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick PHP stopped working on update

Post by fmw42 » 2016-05-21T18:40:42-07:00

I am a little puzzled by your code. I do not see the need for -compose Dst or -compose over since there is no -composite. Settings without operators do nothing. Note I have added -compose over at the end, but even that may not be needed since the default for -composite is -compose over, unless you have used some other compose earlier and I have taken them out.

So, this works fine for me without them.

Code: Select all

convert \( 3_Queens_Parade_300_x_220_8.jpg -write mpr:image +delete \) \
\( 045a-top.png -write mpr:edge_top +delete \) \
\( 045a-bottom.jpg -rotate 180 -write mpr:edge_btm +delete \) \
mpr:image -alpha set -bordercolor 'rgb(107,15,15)' -border 80 \
-frame 24x24+24 \
-transverse -tile mpr:edge_btm \
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
-transverse -tile mpr:edge_top \
-draw 'color 1,0 floodfill' -transpose -draw 'color 1,0 floodfill' \
mpr:image -gravity center -compose over -composite \
result4.jpg
If this does not work, nor the disabling of openmp or limiting the thread to 1, then I would suggest you put in +write tmpX.jpg (x=1,2...) at various places and see where the tmp is failing.

snibgo
Posts: 11994
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imagemagick PHP stopped working on update

Post by snibgo » 2016-05-21T20:15:13-07:00

"-frame" is sensitive to the "-compose" setting, but I don't think "Dst" here gives a different result to "Over".
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 25376
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagemagick PHP stopped working on update

Post by fmw42 » 2016-05-21T20:45:54-07:00

snibgo wrote:"-frame" is sensitive to the "-compose" setting, but I don't think "Dst" here gives a different result to "Over".
Thanks for the pointer. I had not considered that, but I see that it is true at http://www.imagemagick.org/script/comma ... .php#frame

Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Imagemagick PHP stopped working on update

Post by Bonzo » 2016-05-22T01:06:22-07:00

Out of interest I ran the original code on my localhost ( version 6.9.3 ) and had the same result as iwantmedia. Changing to the code below worked - note I had to use \" instead of ' as I am on a windows localhost. I have also added some error reporting and the code should still run on a Linux type server.

Sorry there is still a problem; looking at the output and the original frame the maroon colour is over the g o l d part of the frame and it should be behind it and the picture is over the picture matte edge. It looks like the pictures are composeted in the wrong order. But at least the frame is there!

Code: Select all

$array=array();

exec("convert http://www.westendframes.co.uk/img/gallery/3_Queens_Parade_300_x_220_8.jpg -write mpr:image +delete  http://www.westendframes.co.uk/img/frame/045a-top.png -write mpr:edge_top +delete  http://www.westendframes.co.uk/img/frame/045a-bottom.jpg -rotate 180 -write mpr:edge_btm +delete  mpr:image -alpha set -bordercolor \"rgb(107,15,15)\" -border 80  -compose Dst -frame 24x24+24 -compose over  -transverse -tile mpr:edge_btm -draw \"color 1,0 floodfill\" -transpose -draw \"color 1,0 floodfill\"  -transverse -tile mpr:edge_top  -draw \"color 1,0 floodfill\" -transpose -draw \"color 1,0 floodfill\"  mpr:image -gravity center -composite 123456.jpg 2>&1", $array);  
echo "<br>".print_r($array)."<br>";  
echo "</pre>";

Post Reply