You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP 7.2.6环境下Imagick扩展已安装但调用imagick_readimage报错求助

Troubleshooting the "Call to undefined function imagick_readimage()" Error

Hey there! Let's work through this issue step by step—since your Imagick extension shows up in phpinfo but you're still hitting that undefined function error, there are a few key things to check:

1. Double-Check the Function Name (Most Likely Fix!)

First off—are you using the right function syntax? It’s easy to mix up procedural vs object-oriented calls with Imagick:

  • Recommended object-oriented approach (works with modern Imagick versions):
    $image = new Imagick();
    $image->readImage('path/to/your/image.jpg');
    
  • Procedural approach: If you’re set on using procedural code, make sure you’re using the exact lowercase, underscore-separated function name:
    $image = imagick_readimage('path/to/your/image.jpg');
    

It’s common to accidentally use camelCase (like ImagickReadImage()) or misspell the name, which would throw that undefined function error immediately.

2. Make Sure You’re Editing the Right php.ini File

Sometimes the PHP instance running your web app uses a different php.ini than the one you checked in phpinfo. Here’s how to confirm:

  • Drop a simple PHP file in your web root with this code:
    <?php phpinfo(); ?>
    
  • Open it in your browser and look for the Loaded Configuration File line—this tells you exactly which php.ini your web server is using.
  • If this path doesn’t match the one you edited when installing Imagick, add the extension=imagick.dll line to this correct file, then restart your web server (IIS, Apache, etc.).

3. Confirm Extension & PHP Version Compatibility

PHP 7.2.6 is a specific release, so you need to ensure your Imagick extension is built exactly for PHP 7.2, matching your architecture (x86/x64) and thread safety setting:

  • Check your phpinfo for the Architecture (x86 or x64) and Thread Safety (enabled/disabled) fields.
  • Download the corresponding Imagick DLL from a trusted source (like the PECL archives) that matches these specs.
  • Don’t forget: the PHP extension relies on system-level ImageMagick binaries—make sure those are installed on your server too, and match the extension’s architecture.

4. Restart Your Web Server (Don’t Skip This!)

Even if you added the extension line to php.ini, changes won’t take effect until you restart your web server. For IIS, use IIS Manager to restart; for Apache, use the service manager or command line.

5. Check for Extension Loading Errors

If the extension seems to show up in phpinfo but still isn’t working, check your web server’s error logs or PHP’s error log for messages like "Unable to load dynamic library 'imagick.dll'". This would mean the extension isn’t actually loading properly (phpinfo can sometimes cache old data, so it might show as loaded even if there’s a startup error).


内容的提问来源于stack exchange,提问作者Sheikh Saadi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:55:22