Magento 1.9 – Fix Fatal Error: Class ‘Imagick’ Not Found

magento-1.9

I am trying to change configuration from backend & once i click on "Save config" it displaying below error :

Fatal error: Class 'Imagick' not found in app/code/local/Aitoc/Aitcg/Model/System/Config/Backend/EnableSvgToPdf.php on line 16 [ $imagick = new Imagick(); ]

<?php

class Aitoc_Aitcg_Model_System_Config_Backend_EnableSvgToPdf extends Mage_Core_Model_Config_Data
{
    public function _beforeSave() {
        parent::_beforeSave();
        if ($this->getValue() == 1)
        {
            exec("convert -version", $out, $rcode); //Try to get ImageMagick "convert" program version number.
            //echo "Version return code is $rcode <br>"; //Print the return code: 0 if OK, nonzero if error.

            if (!($rcode === 0))
                throw Mage::exception('Mage_Core', Mage::helper('aitcg')->__('Requires ImageMagick to be installed at your host and allowed php exec command;  check http://www.imagemagick.org/script/formats.php for possible format conversions'));

            try{
            $imagick = new Imagick();
            }
            catch (Exception $e)
            {
                throw Mage::exception('Mage_Core', Mage::helper('aitcg')->__('Requires ImageMagick to be installed at your host and allowed php exec command;  check http://www.imagemagick.org/script/formats.php for possible format conversions'));
            }
            // return $this->_getPromoBlock();

        }

    }

}

system.log :

Warning: include(Imagick.php): failed to open stream: No such file or directory  in lib/Varien/Autoload.php on line 94
Warning: include(): Failed opening 'Imagick.php' for inclusion (include_path='app/code/local:/app/code/community://app/code/core:/lib:.:/usr/share/php:/usr/share/pear')  in /lib/Varien/Autoload.php on line 94

i followed link & i did changes as mentioned in comments .

  1. added this code : if ($class === 'File') { mageDebugBacktrace(); } in /lib/Varien/Autoload.php on line 94 as here : http://pastebin.com/yiZ0cjVy

also followed answer & added code : <cache><backend><![CDATA[File]]></backend</cache> in app/etc/local.xml as below . but still i am facing same issue.

<config>
    <global>
        <install>
            <date><![CDATA[Thu, 31 Mar 2016 10:28:26 +0000]]></date>
        </install>
        <crypt>
            <key><![CDATA[97855aaa840e2283935951360d376dd3]]></key>
        </crypt>
        <disable_local_modules>false</disable_local_modules>
        <resources>
            <db>
                <table_prefix><![CDATA[]]></table_prefix>
            </db>
            <default_setup>
                <connection>
                   <host><![CDATA[localhost]]></host> 

                    <username><![CDATA[grtrtrtt]]></username>
                    <password><![CDATA[trtrtrtrt]]></password>
                    <dbname><![CDATA[trtrtrtrtrtrtrt]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]></pdoType>
                    <active>1</active>
                </connection>
            </default_setup>
        </resources>
        <session_save><![CDATA[files]]></session_save>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>

            </adminhtml>
        </routers>      
    </admin>
    <cache>
    <backend><![CDATA[File]]></backend>    
    </cache>
</config>

or did i wrote code in wrong place in any of above files – Autoload.php / local.xml ?

Best Answer

It seems imagick is not installed on your server.

Install it on server run following command on server

  • pecl install imagick
  • sudo apt-get install php5-imagick && sudo php5enmod imagick

For more information http://php.net/manual/de/book.imagick.php