I have some code which is resizing images, using either Imagick or GD, depending what's available on the server.
I'm testing for availability of each using the extension_loaded() function.
if (extension_loaded('imagick')) {
$image = new Imagick();
...
}
I have one user reporting that they are receiving:
Fatal error: Class 'Imagick' not found
What circumstances would result in the Imagick extension being loaded but the class not available? How should I be testing to make my code more robust?
1: always do the checks in a case-insensitive manner (make the string lowercase before comparing it)
2: don't check for the library, check for features. Maybe it has a library version that's buggy or has other function names
3: in php.ini you may disable some functions explicitly by name so I think you should resort to point #2 and check with function_exists instead of extension_*
Also, take a look at /var/log/apache2/errors or the equivalent on that client's server to check for any internal error generated by the ImageMagick extension (segmentation fault or other types of low-level errors should get reported in there...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With