Page 1 of 1
Problems using some operations on IM 6.7.6-1 2012-03-19 Q16
Posted: 2012-03-21T01:42:28-07:00
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.
Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q
Posted: 2012-03-21T03:36:16-07:00
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.
Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q
Posted: 2012-03-21T03:48:55-07:00
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..
Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q
Posted: 2012-03-21T03:51:24-07:00
by Bonzo
Strange as you say - hopefuly somebody will come along later with the answer.
Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q
Posted: 2012-03-21T15:44:50-07:00
by stefan1982
Im still clueless... Anybody has any ideas on howto find out whats wrong?
Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q
Posted: 2012-03-21T16:36:58-07:00
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.
Re: Problems using rotate/distort on IM 6.7.6-1 2012-03-19 Q
Posted: 2012-03-21T22:35:16-07:00
by stefan1982
Doing a system("which convert"); just returns
"/usr/bin/convert".
Now what?
Re: Problems using some operations on IM 6.7.6-1 2012-03-19
Posted: 2012-03-22T09:33:35-07:00
by fmw42
try
type -a convert
Also can you try your rotate command in a terminal rather than PHP exec?
Re: Problems using some operations on IM 6.7.6-1 2012-03-19
Posted: 2012-03-23T06:15:11-07:00
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?
Re: Problems using some operations on IM 6.7.6-1 2012-03-19
Posted: 2012-03-23T10:19:50-07:00
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
Re: Problems using some operations on IM 6.7.6-1 2012-03-19
Posted: 2012-03-23T16:23:18-07:00
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?
Re: Problems using some operations on IM 6.7.6-1 2012-03-19
Posted: 2012-03-23T17:57:23-07:00
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?
Re: Problems using some operations on IM 6.7.6-1 2012-03-19
Posted: 2012-03-23T18:57:57-07:00
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...
Re: Problems using some operations on IM 6.7.6-1 2012-03-19
Posted: 2012-03-23T19:14:05-07:00
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
Re: Problems using some operations on IM 6.7.6-1 2012-03-19
Posted: 2012-03-23T19:24:10-07:00
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