I have tried to get imagemagick to work for 3 days with no luck.

This is what I did.

I followed this guide.
http://www.imagemagick.org/script/binary-releases.php#macosx

I downloaded ImageMagick-universal-apple-darwin9.7.0.tar.gz and followed the instructions.

imagemagick works perfect from the terminal in leopard, but not from my PHP code.

<?php

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

?>

Can someone please tell me what I need to do to get it work?

I would be very grateful if someone can help me with this.

    I just tried this code.

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

      It means sh (your shell) cannot find convert to execute.

      Add the install path of imagemagick to your environment path or supply the full execution path to your script.

        Can you please tell me how that is done in detail?

        Kudose;10923225 wrote:

        It means sh (your shell) cannot find convert to execute.

        Add the install path of imagemagick to your environment path or supply the full execution path to your script.

          Your best bet is to place the absolute path to imagemagick in your exec call.

          Do you know where you install ImageMagick?

          You can use "find / -name convert" from the Linux CLI to locate imagemagick.

            I did what you said and this is the result (among many others) from the terminal in Mac OS X Leopard.

            Users/dibisutveckling/ImageMagick-6.5.3/bin/convert

            I don't understand why it's not installed in /usr/local/bin/convert

            I also tried this code:

            <?php
            
            $array=array();
            echo "<pre>";
            exec("../ImageMagick-6.5.3/bin/convert logo.gif logo.png 2>&1", $array);
            echo "<br>".print_r($array)."<br>";
            echo "</pre>";
            
            ?>

            I got the following result.

            Array
            (
            [0] => dyld: Library not loaded: /ImageMagick-6.5.3/lib/libMagickCore.2.dylib
            [1] => Referenced from: /Users/dibisutveckling/Sites/../ImageMagick-6.5.3/bin/convert
            [2] => Reason: image not found
            )

            1

            Kudose;10923351 wrote:

            Your best bet is to place the absolute path to imagemagick in your exec call.

            Do you know where you install ImageMagick?

            You can use "find / -name convert" from the Linux CLI to locate imagemagick.

              How did you install ImageMagick?

              Did you download the tarball, extract it then run the install script/make file?

              Did you use a repository?

                I downloaded the following file.

                http://www.imagemagick.org/download/binaries/ImageMagick-universal-apple-darwin9.7.0.tar.gz

                I moved it to my home directory dibisutveckling.

                Then I used the following command in the terminal.

                tar xvfz ImageMagick-universal-apple-darwin9.7.0.tar.gz

                I did not run any script/make file. I don't even know what repository means.

                I'm pretty sure I do this in the wrong way. I'm not used to the terminal.

                Please tell me how to do it in the right way.

                Kudose;10923570 wrote:

                How did you install ImageMagick?

                Did you download the tarball, extract it then run the install script/make file?

                Did you use a repository?

                  ImageMagick is not installed is the problem.

                  The easiest way to install it is using a repo(sitory).

                  Here are the two most common ways to install imagemagick

                  Under RedHat/Fedora/CentOS

                  yum install imagemagick

                  Under Debian/Ubuntu

                  apt-get install imagemagick

                  Run either one of those from the terminal.

                  Alternately, you can go to the directory that you extracted ImageMagick to and see if there is a file called makefile or install

                  If there is a makefile, run

                  make && make install

                  If there is an install file, make it executable by typing

                  chmod +x install

                  Then execute the install file

                  ./install

                  Hope that helps.

                    I just tried apt-get install imagemagick in the terminal but that gave me:

                    command not found.

                    There are no make or install file as far as I can tell.

                    Must I have xtools installed to be able to use apt-get install command, or is the problem something else?

                    Kudose;10923583 wrote:

                    ImageMagick is not installed is the problem.

                    The easiest way to install it is using a repo(sitory).

                    Here are the two most common ways to install imagemagick

                    Under RedHat/Fedora/CentOS

                    yum install imagemagick

                    Under Debian/Ubuntu

                    apt-get install imagemagick

                    Run either one of those from the terminal.

                    Alternately, you can go to the directory that you extracted ImageMagick to and see if there is a file called makefile or install

                    If there is a makefile, run

                    make && make install

                    If there is an install file, make it executable by typing

                    chmod +x install

                    Then execute the install file

                    ./install

                    Hope that helps.

                      I tried only the last part of the script (that installs imagemagick) and everything works very nice until this line:

                      ./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts

                      I get a error message saying:

                      no acceptable C compiler found in $PATH

                      Do I need xtools installed?

                      This is the whole script after I changed imagemagick to the latest version:

                      curl -O [url]ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.5.4-7.tar.gz[/url]
                      tar xzvf ImageMagick-6.5.4-7.tar.gz
                      cd ImageMagick-6.5.4-7
                      export CPPFLAGS=-I/usr/local/include
                      export LDFLAGS=-L/usr/local/lib
                      ./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts
                      make
                      sudo make install
                      cd ..

                      Kudose;10923686 wrote:

                      I forgot you are on Mac Leopard, check out http://www.aldenta.com/2007/11/26/installing-imagemagickrmagick-on-leopard/

                        I installed xcode tools and was able to install Imagemagick in the right directory, usr/local/bin. That is a very good start. But it will still only work from the terminal, not from PHP code.

                        What do I do now to find the problem?

                          To be more specific. I run this 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

                            Try supplying the full input and output path. I believe convert is looking for files local to itself.

                              I have already tried that with the same result. This seems to be a permission problem. I printed out the name of the user that runs the php code and it is www. But how do I set permission for the www user?

                              I also tried this code:

                              <?php
                              exec("export", $output);
                              print_r($output);
                              ?>

                              With the following result:

                              Array (
                              [0] => export OLDPWD
                              [1] => export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
                              [2] => export PWD="/Users/dibisutveckling/Sites"
                              [3] => export SHLVL="1"
                              )

                              Kudose;10923768 wrote:

                              Try supplying the full input and output path. I believe convert is looking for files local to itself.

                                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.

                                  You need to add /usr/local/bin to your PATH

                                    How do I do that in Mac OS X Leopard?

                                    I have heard that it's different compared to Mac OS X Tiger.

                                    Kudose;10923805 wrote:

                                    You need to add /usr/local/bin to your PATH

                                      Write a Reply...