# ImageMagick error code 127



## augr (Dec 12, 2010)

Hello,

I installed ports ImageMagick and pecl-imagick and all seems well but when I write a test page, I get an error: Version return code is 127 

Apparently something to do with paths but I have no idea where to start.

Here's my php install info:
http://actionpixel.com/test/php/env.php

Return code:
http://actionpixel.com/test/php/images/im2.php

I am also running Plesk 8.2 (not sure if this matters)

Much appreciate any help.


----------



## jrm@ (Dec 12, 2010)

Perhpas posting the contents (php code) of im2.php will give some clues.


----------



## augr (Dec 14, 2010)

Good point mingrone.

Here's the code inside im2.php:


```
<html> <head> <title>Test for ImageMagick</title> </head>
<body> <?
function alist ($array) {  //This function prints a text array as an html list.
  $alist = "<ul>";
  for ($i = 0; $i < sizeof($array); $i++) {
    $alist .= "<li>$array[$i]";
  }
  $alist .= "</ul>";
  return $alist;
}
exec("convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number.
echo "Version return code is $rcode 
"; //Print the return code: 0 if OK, nonzero if error.
echo alist($out); //Print the output of "convert -version"

?> </body> </html>
```

Thanks for any assistance.


----------



## augr (Jan 8, 2011)

SOLVED: for FreeBSD users wanting to use ImageMagick in their php scripts, here's what I did to get this to work in this order:

1) update ALL the ports. I used the portsnap method (my ports were way out of date!)
2) update/install libtool port - v2.2 (very important but be careful because apparently other ports depend on libtool and if you botch it, you might create problems. Mine went smoothly)
3) update/install ImageMagick port - v6.6.6
4) update/install pecl-imagick port - v3.0.1 (this gave me a bit of a headache as the checksum was wrong so I manually put the latest version from http://pecl.php.net/package/imagick into the directory the error code told me to add it in)
5) restart machine

That did the trick. Interestingly enough ImageMagick forums didn't provide any answers at all. I would have thought I would find a nice easy tutorial to get IM working on FreeBSD with php but nada. Everyone kept referencing Linux but that doesn't help us.

Hope this saves someone some time and frustration!

Cheers,

Angelo


----------

