daniel__
daniel__

Reputation: 11845

problem with host- imagick

I have a problem with this module.

In my local server i open my php.ini and i have the module imagick in the list. Now i changed the site to a webserver, but in php.ini, the module is not showed.

I talked with the company that have the web server, and the answer is: "the module is installed and show me this:"

root@dime38 [~]# convert
Version: ImageMagick 6.2.8 08/25/10 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html 

but when i use this code:

 <?php

    $image = new Imagick();
    $image->newImage(100, 100, new ImagickPixel('red'));
    $image->setImageFormat('png');

    header('Content-type: image/png');
    echo $image;

    ?>

i simple receive this:

Fatal error: Class 'Imagick' not found in /home/empreg0l/public_html/modulo.php on line 3

But the same code works in my local host. What is the problem? (Probably, the extension is commented in the php.ini? or exists any problem in the code?)

thanks

Upvotes: 1

Views: 713

Answers (4)

Won Jun Bae
Won Jun Bae

Reputation: 5389

apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
cd imagick-3.4.0
phpize
./configure
make install
rm -rf /tmp/imagick-3.4.0*
echo extension=imagick.so >> /etc/php/7.0/cli/php.ini
echo extension=imagick.so >> /etc/php/7.0/fpm/php.ini

From Install Imagick 3.4.0 on PHP 7.0

Upvotes: 0

user188654
user188654

Reputation:

Use get_loaded_extensions to confirm you have the imagick PHP extension installed.

var_dump(get_loaded_extensions());

Upvotes: 0

plusbryan
plusbryan

Reputation: 121

To install imagick for php:

apt-get install php5-imagick

Upvotes: 0

Pekka
Pekka

Reputation: 449783

There is a difference between the ImageMagick binary (which can be called through the convert command) and the IMagick PHP extension. Even if the binary is installed, it doesn't mean the PHP extension is.

Your provider would have to explicitly activate that in their server's PHP.

If they won't do that, you'll have to recreate the IMagick commands as command line options and call it through exec().

Upvotes: 1

Related Questions