本文介绍了imagemagick无法加载远程图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个php脚本,它使用下面的命令下载,重新调整和存储一个映像:
$ b $ $ p $ exec('convert -sample 100x100 http://someurl.com/pic.jpg images / somename.jpg');

这一切都很好,直到我把它放在不同的服务器上(这是一个gentoo,如果这使得任何显然转换不会抓住远程图像,如果我喂它像上面的url它返回

转换:缺少图像文件名'images / somename.jpg'@ convert .c / ConvertImageCommand / 2822。



我检查了使用标志,但似乎没有涉及远程图像...新的服务器是本地机器,我有根访问,所以我几乎可以做任何事情 - 所以我怎么能做到这一点?

另一个可能相关的问题是,PHP的file_get_contents ()不会从那里获得远程文件,也许这是一个系统范围的设置,防止二进制文件获取远程文件?有没有人有过这样的问题?你是如何解决它?



感谢,
b $ b Mala

更新:澄清

这个问题(imagemagick)没有任何关系与PHP。这是在我的笔记本电脑,可以访问互联网就好了,而且不涉及到防火墙。如果我打开一个shell并键入

convert -sample 100x100 http://someurl.com/pic.jpg images / somename.jpg >
上面的错误,甚至没有尝试访问互联网失败。另一方面,'wget'以及网页浏览器等工作得很好。在其他系统上,输入到shell的convert命令没有任何错误。



请忽略file_get_contents问题,因为我认为这个问题与原因无关

解决方案
相反,直观地说,imagemagick必须按照xml支持的顺序编译加载远程图像。因此,Gentoo用户将需要启用 xml useflag。


I have a php script, which downloads, rescales and stores an image using the following command:

exec('convert -sample 100x100 http://someurl.com/pic.jpg images/somename.jpg');

It all worked fine until I put it on a different server (this one's gentoo, if that makes any difference. Apparently convert won't grab remote images, and if I feed it a url like above it returns
convert: missing an image filename 'images/somename.jpg' @ convert.c/ConvertImageCommand/2822.

I checked the use flags but nothing seems to relate to remote images...The new server is a local machine which I have root access to, so I can pretty much do whatever on it - so how can I make this work?

Another possibly related issue is that php's file_get_contents() won't get remote files from there either. Maybe it's a system-wide setting somewhere preventing binaries from getting remote files? Has anyone had an issue like this before? How did you solve it?

Thanks,
Mala

Update: To clarify
This problem (imagemagick) has nothing to do with PHP. It's on my laptop which can access the internet just fine, and is not related to firewalls. If I open up a shell and type
convert -sample 100x100 http://someurl.com/pic.jpg images/somename.jpg
it fails with the above error without even trying to access the internet. 'wget' on the other hand, as well as web-browsers etc work just fine. On other systems, the convert command when typed into a shell works with no errors.

Please disregard the file_get_contents problem as I believe it is not related for the reasons above

解决方案

Rather unintuitively, imagemagick must be compiled with the xml support in order to load remote images. Thus, Gentoo users will need to enable the xml useflag.

这篇关于imagemagick无法加载远程图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 06:30