Apache + php problem creating Shadows

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tomcontr

Apache + php problem creating Shadows

Post by tomcontr »

Hi,

Im having some problems with Apache each time I try to create thumbs with Shows.
This is the code:

Code: Select all

system("/usr/bin/convert $file1 -bordercolor white -border 6 -bordercolor grey60 -border 1 -background  black \( +clone -shadow 60x4+4+4 \)  +swap -background  none -flatten $file3");
If I execute that code from apache : ie. http://www.mywebsite.com/file.php
Nothing happens, no error message nothing. The file is not created. But if I execute that file.php from the command line, the file is created.

Now, I thought it might be a permision issue, but its wird, beause if I remove this part from the command: \( +clone -shadow 60x4+4+4 \) +swap
then the code works, so clearly I can execute convert from apache, it just that some of the options are allowed and in this case -shadow is not...

So the question is, Does anyone knows why that particular option can be affected being called from Apache?

Hope that some can help me.

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

Re: Apache + php problem creating Shadows

Post by fmw42 »

Possibly multiple version of IM (one too old)?

try

which convert

and see if you have more than one version and what they are
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Apache + php problem creating Shadows

Post by Bonzo »

As Fred says your version may be to old and there could be two different versions on the server; use this code to display the version number php is using and any errors that IM returns:

Code: Select all

<?php
echo "<pre>";
system("convert -version");  
echo "</pre>";

$array=array();
echo "<pre>";
system("/usr/bin/convert $file1 -bordercolor white -border 6 -bordercolor grey60 -border 1 -background  black \( +clone -shadow 60x4+4+4 \)  +swap -background  none -flatten $file3 2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
?> 
Use this to see what vewrsion the comand line is using:

Code: Select all

convert -version
tomcontr

Re: Apache + php problem creating Shadows

Post by tomcontr »

There are 2, but they are the same.

-bash: /usr/local/bin/convert -version
Version: ImageMagick 6.2.8 02/25/09 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC

-bash: /usr/bin/convert -version
Version: ImageMagick 6.2.8 02/25/09 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC
tomcontr

Re: Apache + php problem creating Shadows

Post by tomcontr »

Bonzo wrote:As Fred says your version may be to old and there could be two different versions on the server; use this code to display the version number php is using and any errors that IM returns:

Code: Select all

<?php
echo "<pre>";
system("convert -version");  
echo "</pre>";

$array=array();
echo "<pre>";
system("/usr/bin/convert $file1 -bordercolor white -border 6 -bordercolor grey60 -border 1 -background  black \( +clone -shadow 60x4+4+4 \)  +swap -background  none -flatten $file3 2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
?> 
Use this to see what vewrsion the comand line is using:

Code: Select all

convert -version

here is the output of that:

Code: Select all

Version: ImageMagick 6.2.8 02/25/09 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC


/usr/bin/convert: Unrecognized option (+clone).
1
1
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Apache + php problem creating Shadows

Post by Bonzo »

What happens if you use convert rather than /usr/bin/convert
tomcontr

Re: Apache + php problem creating Shadows

Post by tomcontr »

it worked!.... wird... Thanks!!
Do you know why?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Apache + php problem creating Shadows

Post by Bonzo »

I think you may have 3 versions of IM on the server ! I assume it is something to do with the paths; you were specifying the path where I presume plain convert uses a default.

Anyway here is a way to create the image without +clone:

Code: Select all

exec(" convert input.png -write mpr:image +delete ( mpr:image -background black -shadow 60x4+5+5 ) mpr:image -composite shadow.png ");
tomcontr

Re: Apache + php problem creating Shadows

Post by tomcontr »

Maybe I did something wrong and I thought it was working, but not. Using only the "convert" statement Im still getting the "convert: Unrecognized option".

I re checked and there is only 1 versión of IM installed....

Any idea?

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

Re: Apache + php problem creating Shadows

Post by Bonzo »

If +clone is not supported you will either have to update or modify the example I posted above.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Apache + php problem creating Shadows

Post by fmw42 »

tomcontr wrote:Maybe I did something wrong and I thought it was working, but not. Using only the "convert" statement Im still getting the "convert: Unrecognized option".

I re checked and there is only 1 versión of IM installed....

Any idea?

Thanks

IM 6.2.8 is very old and may not have all the features you need or some may not be working well. That version is over 350 versions old! -shadow uses layers merge which was not introduced until 6.3.6-2 see http://www.imagemagick.org/Usage/blur/#shadow
tomcontr

Re: Apache + php problem creating Shadows

Post by tomcontr »

No clearly its not the version. If I execute the php file from the command line it works, and its the exact same version.

Could it be a library problem or something??
tomcontr

Re: Apache + php problem creating Shadows

Post by tomcontr »

I found the problem.... indeed there is an older version of IM. ImageMagick 5.5.6.
As its a Hosting server I cant do anything about it, so the only thing I can do is try to do the same shadow using that version. Is that posible? which commands should I use?

Thanks in advance.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Apache + php problem creating Shadows

Post by anthony »

IM v5 is dated back to 2002 it is next to imposible to do anything of real compexity with it

You have to read modify and save the image for EVERY operation

You have no shadow command, distort, variable blurs or other enhancments

and it has so many bugs that have been fixed over the years, including some very important security bugs.

I would suggest that you ask them to upgrade, even if it is just from a security point of view!!!!

Could two versions of IM exist on the host? Maybe you can select between them?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Apache + php problem creating Shadows

Post by fmw42 »

If this is Godaddy, they have two version of IM (v5x and v6.2.8 ). I believe that v5 is at /usr/bin and v6 is at /usr/local/bin But I have had no success in getting them to upgrade at all.

You might try another ISP. I hear that Hostgator may be more inclined to upgrade or install a special version for you.
Post Reply