php.net |  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: 2014-01-21 13:50 UTC
Votes:15
Avg. Score:3.9 ± 0.9
Reproduced:14 of 15 (93.3%)
Same Version:10 (71.4%)
Same OS:7 (50.0%)
From: filip dot karas at gmail dot com Assigned: mkoppanen
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
Description:
------------
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)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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] mike@php.net
-Assigned To: +Assigned To: mkoppanen
 [2014-01-21 11:39 UTC] tomkrawc at gmail dot com
Guys!

It was reported in the past. See https://bugs.php.net/bug.php?id=59594

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.

cheers
 [2014-01-21 13:50 UTC] mkoppanen@php.net
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.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 04:01:57 2014 UTC