Problems using some operations on IM 6.7.6-1 2012-03-19 Q16

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
stefan1982
Posts: 7
Joined: 2012-03-21T01:11:00-07:00
Authentication code: 8675308

Problems using some operations on IM 6.7.6-1 2012-03-19 Q16

Post by stefan1982 »

Path to convert: /usr/bin/convert
Path to files _is_ writable!
Using PHP 5.3.

Return of system("type convert"):
Version: ImageMagick 6.7.6-1 2012-03-19 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

I talked to the system consultant, which told me he recently did an upgrade of ImageMagick on the server, using the default options.

Doing the following doesn't work, neither does it work for anything else than 90/180/270 for -rotate:
system("/usr/bin/convert files/input.png -rotate '-110' files/output.png");

Doing the following does work:
system("/usr/bin/convert files/input.png -rotate '90' files/output.png");
system("/usr/bin/convert files/input.png -rotate '-90' files/output.png");
system("/usr/bin/convert files/input.png -rotate '180' files/output.png");

So, I tried to use the -distort to build around the problem, which doesn't work either:
system("/usr/bin/convert files/input.png -background skyblue -virtual-pixel background -distort ScaleRotateTranslate -110 file/output.png");

I'm pretty sure IM is installed, although I think it's _really_ strange these functions are not working. Is there someone, who could help me?
I am able to test out commands using PHP's system() and exec() functions.

I hope someone could help me with this, as I'm pretty much loosing it.
Last edited by stefan1982 on 2012-03-22T02:52:35-07:00, edited 1 time in total.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q

Post by Bonzo »

Try this to see what error if any are returned:

Code: Select all

<?php 
$array=array(); 
echo "<pre>"; 
exec("/usr/bin/convert files/input.png -rotate -110 files/output.png 2>&1", $array);  
echo "<br>".print_r($array)."<br>";  
echo "</pre>"; 
?> 
I do not think you need ' ' around the angle and I use exec( ) rather than system, unless I need information displayed on the screen.
stefan1982
Posts: 7
Joined: 2012-03-21T01:11:00-07:00
Authentication code: 8675308

Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q

Post by stefan1982 »

It gives me an empty array();

Strange thing is that the following does work:
system("/usr/bin/convert $input -background none -shear 20 $output");

But everything I try using the "-rotate" or "-/+distort ScaleRotateTranslate" or "-/+distort SRT".
Only rotate works with 90/180/270, distort doesn't do that either..

Quite strange, right? I have no idea where to look now..
If I do a system("/usr/bin/convert -list") I get all the operations mentioned before..
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q

Post by Bonzo »

Strange as you say - hopefuly somebody will come along later with the answer.
stefan1982
Posts: 7
Joined: 2012-03-21T01:11:00-07:00
Authentication code: 8675308

Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q

Post by stefan1982 »

Im still clueless... Anybody has any ideas on howto find out whats wrong?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q

Post by fmw42 »

check to see if you have more than one version of IM on the system and which version that PHP exec is using. sounds perhaps like the install was not clean or there might be multiple versions conflicting. however, I am no expert on installs.
stefan1982
Posts: 7
Joined: 2012-03-21T01:11:00-07:00
Authentication code: 8675308

Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q

Post by stefan1982 »

Doing a system("which convert"); just returns
"/usr/bin/convert".

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

Re: Problems using some operations on IM 6.7.6-1 2012-03-19

Post by fmw42 »

try

type -a convert

Also can you try your rotate command in a terminal rather than PHP exec?
stefan1982
Posts: 7
Joined: 2012-03-21T01:11:00-07:00
Authentication code: 8675308

Re: Problems using some operations on IM 6.7.6-1 2012-03-19

Post by stefan1982 »

Fred,

an exec("type -a convert");

gives the following output:


Array
(
[0] => convert is /usr/bin/convert
)

So, this looks okay.. I could not try the command in a terminal, I do not have the permissions todo so.
Any more idea's on how to solve the issue?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems using some operations on IM 6.7.6-1 2012-03-19

Post by fmw42 »

Only thing I can suggest is to have IM unistalled and then reinstalled.

Or first, have your ISP test your simple rotate command and see if they can reproduce the fact that it does not rotate.

Or check your file permissions for those folders

Or do a test without specifying the folders -- put all the images in the same folder as your script -- hard code the image names

Or specify the full path from your root to the folders
stefan1982
Posts: 7
Joined: 2012-03-21T01:11:00-07:00
Authentication code: 8675308

Re: Problems using some operations on IM 6.7.6-1 2012-03-19

Post by stefan1982 »

fmw42 wrote:Only thing I can suggest is to have IM unistalled and then reinstalled.

Or first, have your ISP test your simple rotate command and see if they can reproduce the fact that it does not rotate.
I will do that, as we speak...
fmw42 wrote: Or check your file permissions for those folders
As a simple exec("/usr/bin/convert files/test.jpg -resize 200x200 files/test_image.png") does the job succesfully, I don't think that this is an issue. Do you agree?
fmw42 wrote: Or do a test without specifying the folders -- put all the images in the same folder as your script -- hard code the image names
I did that before, with no success. Strange thing is that simple things like -resize work, but things like -/+rotate/-thumbnail/-polaroid - and probably more operations - fail..
fmw42 wrote: Or specify the full path from your root to the folders
Did that to, but as noted earlier -resize works. To me it looks like the installation/upgrade of IM is buggy. What do you think?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems using some operations on IM 6.7.6-1 2012-03-19

Post by fmw42 »

If your ISP can do the rotate from a terminal/shell, then IM is OK. If that fails, then have them uninstall and reinstall. If they can do it from the terminal/shell and not from PHP exec, then PHP may have some problems on your account or in their system. Sorry, that is about all that I can think of. You have already done the other tests successfully. Wonder if there is some kind of alias set up for rotate in your server or in your account?
stefan1982
Posts: 7
Joined: 2012-03-21T01:11:00-07:00
Authentication code: 8675308

Re: Problems using some operations on IM 6.7.6-1 2012-03-19

Post by stefan1982 »

fmw42 wrote:If your ISP can do the rotate from a terminal/shell, then IM is OK. If that fails, then have them uninstall and reinstall. If they can do it from the terminal/shell and not from PHP exec, then PHP may have some problems on your account or in their system.
I'll contact them and tell them this is what they should do.
fmw42 wrote:Sorry, that is about all that I can think of. You have already done the other tests successfully.
No reason to apoligise, I'm very happy you are willing to help. You did a great job helping me, although it aint solved the issue (yet).
fmw42 wrote:Wonder if there is some kind of alias set up for rotate in your server or in your account?
How do you mean? Alias set for rotate? Strange thing is that it does rotate, but only 90/180/270/0 degrees. Not anything in between..
So, the following works:
exec("/usr/bin/convert $image -rotate 90 $image");
exec("/usr/bin/convert $image -rotate 180 $image");
exec("/usr/bin/convert $image -rotate 270 $image");

But - as an example this fails:
exec("/usr/bin/convert $image -rotate 30 $image");
exec("/usr/bin/convert $image -rotate -5 $image");
exec("/usr/bin/convert $image -rotate 110 $image");

Even stranger is, that -shear works:
exec("/usr/bin/convert $image -shear 30 $image")
exec("/usr/bin/convert $image -shear -5 $image");
exec("/usr/bin/convert $image -shear 110 $image");

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

Re: Problems using some operations on IM 6.7.6-1 2012-03-19

Post by fmw42 »

Internally rotate of 90 degrees are special operations that work much faster than non-90 degree rotations. They are similar to -flip and -flop. So I am not surprised that 90 degree increments work but non-90 multiples do not. Does -distort SRT 10 work? What about -distort SRT 90?

Just as a sanity check. Put your angles in quotes and see if that makes a difference.


What size is your image? Is it very large? Try with a small image of say size 128x128
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problems using some operations on IM 6.7.6-1 2012-03-19

Post by fmw42 »

What server platform are you on? Some servers do not like OpenMP. So if you have them re-install IM as a last resort have then disable OpenMP in the configure file. Add --disable-openmp to the ./configure command
Post Reply