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
Copyright Notice:Content Author:「filip.karas」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/9954764/imagick-php-5-4-extension-does-not-work-with-relative-paths-windows