I'm trying to install imagick PHP extension on windows. It was working on PHP 5.2, PHP 5.3 but I have problems with PHP 5.4.
Imagick version: ImageMagick-6.7.6-3-Q16-windows-dll. Module is working. I can see imagick in phpinfo().
The problem is, that imagick does not recognize relative path to files. For example, if I have simple index.php and a.jpg in the same folder, I can't use $im = new imagick('a.jpg');
because I get exception:
Fatal error: Uncaught exception 'ImagickException' with message 'unable to open image `a.jpg': No such file or directory @ error/blob.c/OpenBlob/2614' in D:\Web\i\index.php:3 Stack trace: #0 D:\Web\i\index.php(3): Imagick->__construct('a.jpg') #1 {main} thrown in D:\Web\i\index.php on line 3
But when I use absolute path $im = new imagick('D:\web\i\a.jpg');
it is working.
I found out, that Imagick is using Apache core dir as reference. I saved the image without path:
$im->writeImage( 'this-is-what-im-looking-for.jpg' );
And I found it in C:\Program Files (x86)\Apache24\this-is-what-im-looking-for.jpg
The problem is, that all my old scripts are written with relative paths and I would like to countinue using them.
I don't know, if the problem is in imagick itself, or somewhere in PHP 5.4.
Thank You in advance
Sounds like you might have unearthed a bug.
I'd suggest reporting it at http://bugs.php.net/report.php
In the meantime, you could work around it by using __DIR__
or __FILE__
to construct an absolute path.
For example, to use the script's directory, do the following:
$im = new imagick (__DIR__ . DIRECTORY_SEPARATOR . 'a.jpg');