imagemagick unable to load remote images
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 ca开发者_如何学编程n 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,
MalaUpdate: 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 typeconvert -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
The first thing that comes to mind is a permission problem. Check the permissions on the target directory. make sure imagemagick can actually save files there.
Remember that PHP run from the http server runs with different permissions than running from the commandline.
DC
Are you able to retrieve other resources via HTTP?
If not then the server likely has a firewall enabled which is preventing access (as you mentioned PHP file_get_contents() function fails also).
If you are able to retrieve other resources via HTTP then the server you're attempting to grab the image from could be blocking you access for some reason.
Its also important to note that any calls to exec will run the program as the same user as PHP, so make sure the user PHP runs as does not have any permission issues.
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.
精彩评论