Question

Okay, Here's a breakdown of what's up:

  1. <? $foo = new Imagick(); ?> works without error when ran from the command-line (e.g., sudo php myscript.php
  2. However, when run via the web browswer I get Fatal error: Class 'Imagick' not found in /var/www/lhackwith_www/test_html/magic.php on line 1.
  3. magickwand is not installed
  4. extension=imagick.so is in imagick.ini which is successfully being read according to phpInfo();
  5. However, imagick is NOT showing up in PHP info.

Any advice would be appreciated.

Was it helpful?

Solution

I take it you're absolutely sure you've edited the right php.ini...
Did you check the webserver's error.log for hints? You might want to increase the LogLevel for that test. If it's an apache see http://httpd.apache.org/docs/2.2/mod/core.html#loglevel and http://httpd.apache.org/docs/2.2/logs.html#errorlog

or maybe ldd - print shared library dependencies can shed some light on the issue:

<?php
$p = get_cfg_var('extension_dir');
$modpath = $p.DIRECTORY_SEPARATOR.'imagick.so';
echo $modpath, is_readable($modpath) ? ' readable':' not readable', "<br />\n";
echo '<pre>';
passthru('ldd '.$modpath.' 2>&1'); // in case of spaces et al in the path-argument use escapeshellcmd()
echo '</pre>';
please run this script both on the command line and through the webserver. Does it complain about a missing dependency?


edit2: So the script running "within" the webserver isn't even able to see the extension .so... Let's test at which point of the path the trouble starts
<?php
function foo($path) {
  if ( $path==($dir=dirname($path)) ) {
    return;
  }
  foo($dir);

echo is_dir($path) ? ' d':' -', is_readable($path) ? 'r':'-', is_writable($path) ? 'w':'-', is_executable($path) ? 'x ':'- ', $path, "<br />\n"; }

$modpath = get_cfg_var('extension_dir').DIRECTORY_SEPARATOR.'imagick.so'; foo($modpath);

OTHER TIPS

I had a similar problem with imagick after upgrading ubuntu from 12.04 to 12.10.

After much fiddling I eventually discovered that there is a different package needed (for php5?) and fixed it with:

sudo apt-get install php5-imagick

What operating system are you using? I've had several problems on Mac OSX that basically makes installing some extensions OVERLY painful. However, the Imagick install should be really simple, for most operating systems.

On your command line, type php -i | grep ini, and make sure the php.ini that is listed as being loaded is the same as the php.ini that phpinfo() says is being loaded. If these are different, that's where you have to start. Make sure extension=imagick.so is in both ini files, also - verify that they are loading extensions from the same directory (99% chance they will be, but who knows - you could be an exception).

After you've verified that (possibly) both php.ini files are loading imagick.so and it's still not working, try to tail -f /path/to/apache/error_log (assuming you're using apache, of course..) and restart apache. You're looking here for php warnings about loading libraries and/or extensions. Hopefully it will point you in the right direction.

Hope this helps,

Jim

What I ended up doing:

Storing the orientation of the image in the DB and then using alternatiff to dynamically rotate the image to the orientation that was stored. No image manipulation needed.

Thanks for your help though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top