Page 1 of 1

Struggling to install Imagick php extension [SOLVED]

Posted: 2016-04-12T04:58:44-07:00
by vinny38
Hi all,
I can't figure out how to install Imagick php extension on my local Apache Server.

I use EasyPHP 14.1
PHP version is 5.5.8

I did install ImageMagick 6.9.3-8 Q8 x64, seems to work fine.

Then I downloaded php_imagick-3.1.2-5.5-ts-vc11-x86 package from https://pecl.php.net/package/imagick/3.1.2/windows

Then copied php_imagick.dll file to C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\binaries\php\php_runningversion\ext
and copied CORE...dll files to C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\binaries\apache\bin

Finally I added 'extension=php_imagick.dll' into my php.ini file

I also installed Ghostscript 9.19

At this point, all seems fine.
The EXEC console 'identify -list format' command line returns many formats, including pdf.

Now, let's test the IM extension:

Code: Select all

<?php 
$imagick = new Imagick($_SERVER['DOCUMENT_ROOT']  .'/projects/mypath/test-imagick.pdf'); 
$imagick->readImage($_SERVER['DOCUMENT_ROOT'] .'/projects/mypath/test-imagick.pdf'); 
$imagick->writeImages($_SERVER['DOCUMENT_ROOT']  .'/projects/mypath/convertedtestimagick.jpg', false); 
?>
Then, I got this :

Code: Select all

Fatal error: Uncaught exception 'ImagickException' with message 'NoDecodeDelegateForThisImageFormat `C:/Program Files (x86)/EasyPHP-DevServer-14.1VC11/data/localweb/projects/caue-mypath/test-imagick.pdf' @ error/constitute.c/ReadImage/555' in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\mypath\test.php:10 Stack trace: #0 C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\mypath\test.php(10): Imagick->__construct('C:/Program File...') #1 {main} thrown in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\mypath\test.php on line 10
:( :( :(

Could someone tell me where I got it wrong?
Thanks in advance for your help

Vinny

Re: Struggling to install Imagick php extension

Posted: 2016-04-12T05:17:27-07:00
by snibgo
When PHP fails in calls IM to convert from PDF, a common solution is to adjust delegates.xml so ghostscript has the full path.

Re: Struggling to install Imagick php extension

Posted: 2016-04-12T05:24:57-07:00
by vinny38
Hi snigbo...
thanks for your answer.

How exactly would you do that??

Besides, I find strange that phpinfo() shows no supported format for IM :
Image

Cheers

Re: Struggling to install Imagick php extension

Posted: 2016-04-12T05:54:25-07:00
by vinny38
In addition:

Image

Re: Struggling to install Imagick php extension

Posted: 2016-04-12T07:51:09-07:00
by Bonzo
Imagemagick is an external program and is unlikely to show up in the phpinfo output.

Have you tried Imagick on a different type of file e.g jpg to try and isolate the problem?

Re: Struggling to install Imagick php extension

Posted: 2016-04-12T07:56:59-07:00
by snibgo
vinny38 wrote:In addition:
Yes, so ImageMagick run from the command line can find Ghostscript. But when it is run from PHP, perhaps it can't.

Re: Struggling to install Imagick php extension

Posted: 2016-04-12T08:24:29-07:00
by vinny38
Have you tried Imagick on a different type of file e.g jpg to try and isolate the problem?
OK, i tried a very basic

Code: Select all

<?php 
$imagick = new Imagick($_SERVER['DOCUMENT_ROOT']  .'/projects/mypath/image.jpg'); 
$imagick->readImage($_SERVER['DOCUMENT_ROOT'] .'/projects/mypath/image.jpg'); 
?>
and the exception "NoDecodeDelegateForThisImageFormat" is thrown again

I feel like I missed something obvious...:?

Re: Struggling to install Imagick php extension

Posted: 2016-04-12T08:42:28-07:00
by Bonzo
I am not an Imagick expert but I do not know why you have the image path twice.

I would now try something even more simple - an image in the same folder as the code.

I know this code worked for me:

Code: Select all

$im = new Imagick('image.jpg');
$im->blurImage( 4, 3 );
$im->writeImage('blured.jpg');
$im->destroy();

Re: Struggling to install Imagick php extension

Posted: 2016-04-21T13:05:19-07:00
by tk1
[b]@vinny38[/b] I see two problems in your installation. You are mixing quantum Q8 (ImageMagick) and Q16 (PHP Imagick). On the pecl site there are only Q16 versions.
Also you should have equal bit versions of PHP and its extensions x64 (PHP Imagick).

If you copy CORE*.dll files to the Apache/PHP directory then You don't need to install ImageMagick cause libraries contain all you need.

I don't copy CORE*.dll files to the Apache/PHP but I set MAGICK_HOME system variable to tell Imagick where libraries are located. Bit versions are equal for IM and Imagick and PHP of course.

Re: Struggling to install Imagick php extension

Posted: 2016-04-25T02:41:14-07:00
by vinny38
@tk1
Hi tk1!
Ok I unistalled everything and followed your instructions from scratch.
I didn't copy CORE*.dll files, and...
everything works fine now!

Thanks for your help! :D