Page 1 of 2

ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-27T01:24:38-07:00
by benny
Dear forum,

I just installed ImageMagick on Mac OS X Leopard. When I open the terminal and type convert -version I get the version number 6.5.4-0, so it's installed. convert -v also works.

But when I run this code in PHP I get a 127 error, and the jpg image is not converted. It works if I type convert mac_mini.jpg mac_min.png in the terminal.

Code: Select all

<?php

exec("convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number.
echo "Version return code is $rcode <br>"; //Print the return code: 0 if OK, nonzero if error.
echo alist($out); //Print the output of "convert -version"

$exec = "convert mac_mini.jpg mac_mini.png";
exec($exec, $yaks);
print_r ($yaks);

?>
Can someone please tell me what the problem is?

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-27T05:13:40-07:00
by Bonzo
Probably a path problem !

Try running this and replace convert with the output which will be something like usr/local/bin/convert

Code: Select all

<?php
echo "<pre>";
// Find the path to ImageMagicks convert comand
system("type convert"); 
// Alternate method
system('which convert',$path);
print_r($path); 
echo "</pre>";
?> 

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-27T05:17:18-07:00
by stroker
I think you need to use the full path to convert.

Use "whereis convert" to find out the full path.
For example /usr/local/bin/convert

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-27T22:01:49-07:00
by benny
When I type locate imagemagick in the terminal I get the following:

/usr/share/zsh/4.3.4/functions/_imagemagick

That seems like a strange place to install imagemagick at.

I follow the instructions on this site:

http://www.imagemagick.org/script/install-source.php

I have tried to include that path in my exec command with no luck.

----------

When I type whereis imagemagick in the terminal I get nothing at all.

----------

This code gives me the answer: 1

<?php
echo "<pre>";
// Alternate method
system('which convert',$path);
print_r($path);
echo "</pre>";
?>

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-28T10:05:04-07:00
by benny
I just tried the following code.

Code: Select all

$array=array();
echo "<pre>";
exec("convert mac_mini.jpg mac_mini.png 2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
And that gave me the following.

Array
(
[0] => sh: convert: command not found
)

1

What does that mean?

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-28T10:46:12-07:00
by Bonzo
As you say it looks like its installed in the wrong place - although I know nothing about mac's !
sh: convert: command not found
This error is basicly saying it can not find the ImageMagick convert program.

Fred is the best person for mac problems and there was a similar problam to yours in the last week and it linked to this post:
viewtopic.php?f=1&t=10442

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-28T11:42:09-07:00
by fmw42
try

find /usr | grep "convert"

It should find this among others.

/usr/local/bin/convert

See what full path you get if not /usr/local/bin/

Note that MacPorts and Fink likely install in a special directory. But if you installed manually, then it should be in /usr/local/bin/

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-29T05:58:13-07:00
by benny
If I install ImageMagick manually (http://www.imagemagick.org/script/binar ... php#macosx), should I install it to /usr/local/bin/ ?

Or will it be installed there automatically?

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-30T21:18:57-07:00
by fmw42
It goes where it wants, but usually to /usr/local/bin.

That is where it goes when I manually install on my Mac OSX Tiger.

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-31T01:03:09-07:00
by benny
Can you please tell me how to install it step by step in detail?

I would appreciate that a lot.
fmw42 wrote:It goes where it wants, but usually to /usr/local/bin.

That is where it goes when I manually install on my Mac OSX Tiger.

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-31T01:31:26-07:00
by benny
I just run the find command in the terminal and I can't find convert anywhere. I think I have installed ImageMagick in the wrong way. Can someone please tell me step by step how I install ImageMagick on Mac OS Leopard?

The only thing I have now is a folder called ImageMagick-6.5.3 in my home directory dibisutveckling.

dibisutvecklings-mac-mini:~ dibisutveckling$ find /usr | grep "convert"
/usr/bin/afconvert
find: /usr/local/bin/pure-pwconvert
/usr/local/man/man8/pure-pwconvert.8
/usr/local/mysql-5.1.36-osx10.5-x86_64/bin/mysql_convert_table_format
/usr/local/mysql-5.1.36-osx10.5-x86_64/data: Permission denied
/usr/local/mysql-5.1.36-osx10.5-x86_64/man/man1/mysql_convert_table_format.1
/usr/local/mysql-5.1.36-osx10.5-x86_64/mysql-test/suite/jp/r/jp_convert_sjis.result
/usr/local/mysql-5.1.36-osx10.5-x86_64/mysql-test/suite/jp/r/jp_convert_ucs2.result
/usr/local/mysql-5.1.36-osx10.5-x86_64/mysql-test/suite/jp/r/jp_convert_ujis.result
/usr/local/mysql-5.1.36-osx10.5-x86_64/mysql-test/suite/jp/r/jp_convert_utf8.result
/usr/local/mysql-5.1.36-osx10.5-x86_64/mysql-test/suite/jp/t/jp_convert_sjis.test
/usr/local/mysql-5.1.36-osx10.5-x86_64/mysql-test/suite/jp/t/jp_convert_ucs2.test
/usr/local/mysql-5.1.36-osx10.5-x86_64/mysql-test/suite/jp/t/jp_convert_ujis.test
/usr/local/mysql-5.1.36-osx10.5-x86_64/mysql-test/suite/jp/t/jp_convert_utf8.test
/usr/local/php5/include/php/ext/mbstring/libmbfl/mbfl/mbfl_convert.h
/usr/local/php5/include/php/ext/standard/cyr_convert.h
/usr/share/doc/libxml2-2.6.16/html/tutorial/includeconvert.c
/usr/share/man/man1/afconvert.1
find: /usr/share/wikid/help/de.lproj/wiki: Permission denied
find: /usr/share/wikid/help/en.lproj/wiki: Permission denied
find: /usr/share/wikid/help/fr.lproj/wiki: Permission denied
find: /usr/share/wikid/help/ja.lproj/wiki: Permission denied
fmw42 wrote:try

find /usr | grep "convert"

It should find this among others.

/usr/local/bin/convert

See what full path you get if not /usr/local/bin/

Note that MacPorts and Fink likely install in a special directory. But if you installed manually, then it should be in /usr/local/bin/

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-07-31T14:31:57-07:00
by fmw42

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-08-02T12:54:05-07:00
by benny
I finally managed to install ImageMagick in the right directory. usr/local/bin

I used this page:

http://www.aldenta.com/2007/11/26/insta ... n-leopard/

I run this code.

PHP Code:
<?php
$array=array();
echo "<pre>";
exec("/usr/local/bin/convert logo.gif logo.png 2>&1", $array);
echo "<br>".print_r($array)."<br>";
echo "</pre>";
?>
And got the following answer.

Array
(
[0] => convert: unable to open image `logo.png': Permission denied @ blob.c/OpenBlob/2480.
)

1

Can someone please tell me what's going on?

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-08-02T23:21:42-07:00
by fmw42
remove the the 2>&1

exec("/usr/local/bin/convert logo.gif logo.png", $array);

the 2>&1 is ONLY used when you have text output as in a script with -h for help information.

be sure you already have logo.gif. Or use the internal IM image called, logo: (with the colon)

Re: ImageMagick is installed (Leopard) but does not work

Posted: 2009-08-03T03:29:23-07:00
by benny
SUCCESS!!!

I changed the permission of my Sites folder to read/write for everyone. After that I got another error message saying:

Convert: no decode delegate for this image format

I had no support for jpg format. SO I downloaded it and installed and now it works to convert a file from jpg to png from PHP with the exec command.

I must write /usr/local/bin/convert and so on to make it work.

How can I get rid of the /usr/local/bin bit of the path? I get a convert command not found error if I do.