'ImagickException' with message 'unable to open file
'ImagickException' with message 'unable to open file /data/web/myweb.com/sub/7/file:/data/web/myweb.com/sub/7/sites/default/files/logo.png'
Hi, I got this message when I want to crete PDF file from the webpage, that png files. It throws error only when content of PDF contains some PNG file. When I remove all png files, that should be in pdf, everything is correct. When I look in php info, I see png is supported format for Imagick. When I tried to find solution on google, it returned many of sites with the same error but almost no solution. the only solution I have found is to install another lib开发者_如何学运维rary to server. But I would prefer another solution if there is any.
thnaks for any advice Tomas
ImageMagick can indeed take png files and convert it to pdf. Are you sure the file is in fact on the server at the correct place.
it feels like the inout command to ImageMagick may be incorrect. The path below looks weird.
data/web/myweb.com/sub/7/file:/data/web/myweb.com/sub/7/sites/default/files/logo.png ^^^^^ Is this expected?
I can tell you more if you tell me the website. Otherwise, I would say its a bug in the website php/python script. It doesn't look like an ImageMagick issue to me.
The ImagickException error message indicates that Imagick (PHP class) is choking on the 'file://' prefix, which is a streamwrapper, fairly recent PHP addition. Imagick documentation is not clear on the use of stremwrappers, and it is most certain that Imagick does not support them. When it sees no '/' in the first byte of the file name, it assumes the file name is relative and pre-pends current directory to it, creating the monster string you pasted in the question.
Solution is to trim the 'file://' prefix on the file name you are sending to the Imagick. File name should be either absolute (start with /) or relative.
if (strpos('file://', $filename) === 0) {
$filename = substr($filename, 7);
}
精彩评论