|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61583 Imagick PHP 5.4 extension does not work with relative paths
Submitted: 2012-03-31 15:32 UTC Modified: 2015-04-01 17:20 UTC
Avg. Score:4.0 ± 0.9
Reproduced:15 of 16 (93.8%)
Same Version:10 (66.7%)
Same OS:8 (53.3%)
From: filip dot karas at gmail dot com Assigned: danack
Status: Assigned Package: imagick (PECL)
PHP Version: 5.4.0 OS: Windows 7
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-03-31 15:32 UTC] filip dot karas at gmail dot com
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 (C:\Program Files 
(x86)\Apache24\ in my case) instead of php file location as reference.

Test script:
This is NOT working

$im = new imagick('a.jpg');

This is working

$im = new imagick(realpath('a.jpg'));

(assumming a.jpg is in the same directory as .php file)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-26 19:05 UTC] nick at moc10media dot com
I had the exact same problem, but in PHP 5.3.10 on Windows 7. I can see it fine in phpinfo(), and I go to run a script passing the relative path of an image file to Imagick, and it crashes.

I did not use to have this problem until I upgraded to IM 6.7.6. So that leads me to believe that the issue is either with IM or the IM PHP extension? Any thoughts?
 [2013-12-03 11:31 UTC]
-Assigned To: +Assigned To: mkoppanen
 [2014-01-21 11:39 UTC] tomkrawc at gmail dot com

It was reported in the past. See

I'm not sure but this exception suggests it is not an Imagick's but ImageMagick's problem. 

If it could be fixed it would be great cause on Linuxes relative paths are working.

 [2014-01-21 13:50 UTC]
Hello, what is the return value of getcwd in your script?
 [2014-01-21 14:07 UTC] tomkrawc at gmail dot com
getcwd() returns D:\wamp\www\imagick

In this directory I have examples from imagick and image file.
 [2015-04-01 17:20 UTC]
-Assigned To: mkoppanen +Assigned To: danack
 [2015-04-01 17:20 UTC]
Assigning to myself to investigate.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Thu Nov 26 19:01:33 2015 UTC