ImageMagick is installed (Leopard) but does not work

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?".
benny

ImageMagick is installed (Leopard) but does not work

Post 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?

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

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

Post 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>";
?> 

stroker
Posts: 16
Joined: 2008-04-07T11:24:55-07:00

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

Post 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

benny

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

Post 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>";
?>

benny

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

Post 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?

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

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

Post 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

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

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

Post 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/

benny

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

Post 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?

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

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

Post 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.

benny

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

Post 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.

benny

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

Post 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/

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

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

Post by fmw42 »


benny

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

Post 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?

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

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

Post 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)

benny

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

Post 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.

Locked