|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 20:00:01 2025 UTC |
There isn't going to be a perfect solution. Imagick can pass things that are not valid filenames to ImageMagick, and this greatly confuses the PHP virtual directory. For example `new Imagick("foo.pdf[2]")` would load the 3rd page of a PDF as a single image, but it is not a valid filename.Realpath () returns an ordinary ANSI/ISO string but Imagick requires this to be in UTF-8, so if there are any unusual characters in the path, this has to be converted first: $im = new Imagick (utf8_encode (realpath ("some_file.jpg")));