Imagick don't want to work with php

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.
Locked
biryuk
Posts: 3
Joined: 2014-10-18T09:34:02-07:00
Authentication code: 6789

Imagick don't want to work with php

Post by biryuk »

Hello
I have Win 7 64 bit, apache 2.2, where I did update php from 5.3 to 5.5 version. php_imagick.dll already was there. Downloaded from php.net

phpinfo() show:
php 5.5.9
VC11
x86
Thread Safety - enabled

I installed ImageMagick into windows, im version 6.8.9 Q16 32 bit. Command convert in command prompt working
But when I uncommented extension php_imagick.dll in php.ini and restart apache, it was with error about CORE_RL_wand_.dll
I downloaded archive php_imagick-3.1.2-5.5-ts-vc11-x86 from here http://windows.php.net/downloads/pecl/r ... ick/3.1.2/. There are php_imagick.dll and CORE_RL_...dll files (including CORE_RL_wand_.dll). I copied this files with replacement in directory where ImageMagick was installed. After apache restart I didn't saw errors and phpinfo() showed me that Imagick lib included.

Image

But in php scripts imagick functions don't work and from command prompt also stopped working. In command prompt I get this error

Image

I copied file IM_MOD_RL_JPG_.dll from ImageMagick_setup_dir/modules/coders/ to ~/.magick and saw new error "not found the specified procedure"

Image

Help me please, I'm in a deadlock

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagick don't want to work with php

Post by fmw42 »

I know very little about this. But your PHP.ini seems to show that Imagick wants version 6.8.8-4 of Imagemagick and you intalled version 6.8.9.x. Perhaps there is a conflict.

biryuk
Posts: 3
Joined: 2014-10-18T09:34:02-07:00
Authentication code: 6789

Re: Imagick don't want to work with php

Post by biryuk »

Thank you for idea, I downloaded archive ImageMagick-6.8.8-4-Q16-x86-windows.zip from this page http://ftp.sunet.se/pub/multimedia/grap ... /binaries/ and replaced Imagick folder which was installed earlier on the correct version. Now I have correct Imagick work from command prompt and correct includes Imagick library in php. But when I try to run php script on web page, I see error in this string $imagick->readImage($_SERVER['DOCUMENT_ROOT'].'/cs.jpg');
Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `Z:/home/site/htdocs/cs.jpg' @ error/constitute.c/ReadImage/555' in Z:\home\site\htdocs\info.php:9 Stack trace: #0 Z:\home\site\htdocs\info.php(9): Imagick->readimage('Z:/home/site...') #1 {main} thrown in Z:\home\site\htdocs\info.php on line 9
I experimented with different file paths:
string $imagick->readImage('cs.jpg'); and $imagick->readImage('/cs.jpg');
gives error
Fatal error: Uncaught exception 'ImagickException' with message 'unable to open image `cs.jpg': No such file or directory @ error/blob.c/OpenBlob/2642' in Z:\home\site\htdocs\info.php:9 Stack trace: #0 Z:\home\site\htdocs\info.php(9): Imagick->readimage('cs.jpg') #1 {main} thrown in Z:\home\site\htdocs\info.php on line 9
File cs.jpg is near with my script

Image

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

Re: Imagick don't want to work with php

Post by Bonzo »

Have you tried a different image or format?

Has your code ever worked?

What is you full code for the Imagemagick section and what are you trying to do?

EDIT:

I have just remembered you have to read the file into a variable first if you want to use readimagefile:

Code: Select all

<?php
$handle = fopen('http://example.com/foo.jpg', 'rb');
$img = new Imagick();
$img->readImageFile($handle);
$img->resizeImage(128, 128, 0, 0);
$img->writeImage('images/foo.jpg');
?> 
This example came from the Imagemagic section of the official php website http://php.net/manual/en/imagick.readimagefile.php

biryuk
Posts: 3
Joined: 2014-10-18T09:34:02-07:00
Authentication code: 6789

Re: Imagick don't want to work with php

Post by biryuk »

Tried png file, get similar error
Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `Z:\home\site\htdocs/cs.png' @ error/constitute.c/ReadImage/555' in Z:\home\site\htdocs\info.php:9 Stack trace: #0 Z:\home\site\htdocs\info.php(9): Imagick->readimage('Z:\home\site...') #1 {main} thrown in Z:\home\site\htdocs\info.php on line 9
I installed Imagick in first time, my code is simply for test of work Imagick library

Code: Select all

<?
ini_set('display_errors',1);
error_reporting(E_ALL);




$imagick = new Imagick();
$imagick->readImage(__DIR__.'/cs.png'); // or $_SERVER['DOCUMENT_ROOT'].'/cs.jpg' no difference
$imagick->writeImages('cs.png', false);
?>
I used readImage function, but I tested your code, it created error too

code

Code: Select all

$handle = fopen('cs.jpg', 'rb');
$img = new Imagick();
$img->readImageFile($handle); // <-- 14 line number
$img->resizeImage(128, 128, 0, 0);
$img->writeImage('foo.jpg');
error
Fatal error: Uncaught exception 'ImagickException' with message 'no decode delegate for this image format `C:/Users/user/AppData/Local/Temp/magick-345269A4bkTBJ9_9' @ error/constitute.c/ReadImage/555' in Z:\home\site\htdocs\info.php:14 Stack trace: #0 Z:\home\site\htdocs\info.php(14): Imagick->readimagefile(Resource id #3) #1 {main} thrown in Z:\home\site\htdocs\info.php on line 14

Locked