Imagick works on version check, but gives fatal error on creating instance of a class.

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
BlissDirect
Posts: 9
Joined: 2016-05-06T08:44:15-07:00
Authentication code: 1151

Imagick works on version check, but gives fatal error on creating instance of a class.

Post by BlissDirect »

I am trying ImageMagick on 1and1 hosting.

Agent from 1and1 hosting said, Upon checking, You have successfully installed the ImageMagick, it will not show up in phpinfo since this was not installed in our server's backend, this was installed within you're hosting space. You need to use the path where you installed the ImageMagick so you can use it.

When I added this code:

Code: Select all

echo '<h2>Test for versions and locations of ImageMagick</h2>';
echo '<b>Path: </b> convert<br>';
function alist ($array) {  //This function prints a text array as an html list.
    $alist = "<ul>";
    for ($i = 0; $i < sizeof($array); $i++) {
        $alist .= "<li>$array[$i]";
    }
    $alist .= "</ul>";
    return $alist;
}
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.
echo alist($out); //Print the output of "convert -version"
echo '<br>';
echo '<b>This should test for ImageMagick version 5.x</b><br>';
echo '<b>Path: </b> /usr/bin/convert<br>';
exec("/usr/bin/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.
echo alist($out); //Print the output of "convert -version"
echo '<br>';
echo '<b>This should test for ImageMagick version 6.x</b><br>';
echo '<b>Path: </b> /usr/local/bin/convert<br>';
exec("/usr/local/bin/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.
echo alist($out); //Print the output of "convert -version";

echo "<pre>";
system("type convert");  
echo "</pre>";
Results:

Test for versions and locations of ImageMagick

Path: convert
Version return code is 0
Version: ImageMagick 6.6.0-4 2015-11-27 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

This should test for ImageMagick version 5.x
  • Path: /usr/bin/convert
    Version return code is 0
    Version: ImageMagick 6.6.0-4 2015-11-27 Q16 http://www.imagemagick.org
    Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
    Features: OpenMP
    Version: ImageMagick 6.6.0-4 2015-11-27 Q16 http://www.imagemagick.org
    Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
    Features: OpenMP
This should test for ImageMagick version 6.x
  • Path: /usr/local/bin/convert
    Version return code is 127
    Version: ImageMagick 6.6.0-4 2015-11-27 Q16 http://www.imagemagick.org
    Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
    Features: OpenMP
    Version: ImageMagick 6.6.0-4 2015-11-27 Q16 http://www.imagemagick.org
    Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
    Features: OpenMP
    convert is /usr/bin/convert
But when I write a basic php example. It gives a Fatal error: Class 'Imagick' not found.

My confusion is do I need to include any path before writing the basic php code and if yes, then what path should I include?

Thanks in advance!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by fmw42 »

I do not know how to couple Imagemagick to Imagick. But Imagemagick 6.6.0.4 is ancient (over 300 versions old). Perhaps your ISP installed a more current imagemagick in a different location.
BlissDirect
Posts: 9
Joined: 2016-05-06T08:44:15-07:00
Authentication code: 1151

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by BlissDirect »

Hi,

I am using Image Magick for the first time, so might got confused with the terms...Sorry for that! Does that mean, the Image Magick is installed successfully, as it is showing the version details?

Thanks in advance
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by Bonzo »

Imagick is the php API for Imagemagick; check in php.ini to see if it is installed.

Imagemagick used with php tends to be run from exec()
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by fmw42 »

Bonzo, according to the first post, the ISP said that it will not show up in php.ini, because it was installed locally.

"Agent from 1and1 hosting said, Upon checking, You have successfully installed the ImageMagick, it will not show up in phpinfo since this was not installed in our server's backend, this was installed within you're hosting space. You need to use the path where you installed the ImageMagick so you can use it."

I suspect he has an old Imagemagick installed by the ISP and that is what he is catching and not the one privately installed.
BlissDirect
Posts: 9
Joined: 2016-05-06T08:44:15-07:00
Authentication code: 1151

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by BlissDirect »

I didn't got your point, "not the one privately installed" Can we have multiple installation on the server and the steps we followed for installation were:

http://help.1and1.com/hosting-c37630/we ... 49013.html

Kindly advise, if I missed any steps while installing..

Thanks in advance.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by fmw42 »

Sorry, I know nothing about installing on servers. You need to check with your ISP to see where you have installed Imagemagick and how it is found by Imagick. Perhaps you have to install Imagick.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by snibgo »

BlissDirect wrote:Can we have multiple installation on the server and the steps we followed for installation were:
In that link,in step 6, IM was installed to the directory /kunden/homepages/30/d339922114/htdocs/ImageMagick

I suppose you didn't use that exact directory name, but something else.

That is where your IM is.
snibgo's IM pages: im.snibgo.com
BlissDirect
Posts: 9
Joined: 2016-05-06T08:44:15-07:00
Authentication code: 1151

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by BlissDirect »

Hi,

Do I need to use the directory path anywhere?

Thanks in advance.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by snibgo »

You installed a version of IM to a directory. If you don't tell PHP where that version is, PHP won't find it.
snibgo's IM pages: im.snibgo.com
BlissDirect
Posts: 9
Joined: 2016-05-06T08:44:15-07:00
Authentication code: 1151

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by BlissDirect »

Hi,

I am sorry, I might sound weird, but I didn't understood the meaning of assigning path to PHP... Do you mean in php.ini file? Can you please elaborate.

Thanks in advance.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by snibgo »

php.ini rings a bell, but I don't use PHP, so can't advise.
snibgo's IM pages: im.snibgo.com
BlissDirect
Posts: 9
Joined: 2016-05-06T08:44:15-07:00
Authentication code: 1151

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by BlissDirect »

I got to learn new thing from 1and1 hosting team, "just to give you a heads up, under shared hosting there is no option for you to reset your server. You will need to have a server package to have access to the root". While reading the steps to install ImageMagick, the last step is to restart the server. Do you guys feel, this will create a problem? Or I do not need a restart as it is installed in the hosting space?

Thanks in advance.
BlissDirect
Posts: 9
Joined: 2016-05-06T08:44:15-07:00
Authentication code: 1151

Re: Imagick works on version check, but gives fatal error on creating instance of a class.

Post by BlissDirect »

For an update, I was able to install the library successfully, after switching from shared server to dedicated server.
Post Reply