我正在尝试使用ImageMagick进行一些照片操作(当前为裁剪)。我以前用PHP的GD库(在我的本地主机上)取得了预期的结果,但现在主机不支持它,他们建议我改用ImageMagick。问题是,我可以裁剪图像,它是存储在本地:PHP ImageMagick从http
<?php
$four = '4fingers1.jpg';
exec("convert $four -crop 100x100+100+100 test.jpg");
?>
<img src="test.jpg">
没有问题,但是当它来自HTTP源(我的剧本的实际目的)我没有收到图像。该代码如下(我用后一种形式的图像的实际SRC):
$src = $_POST['src'];
exec("convert $src -resize 720x720 resized.jpg"); // this is specified in the documentation
exec("convert resized.jpg -crop 100x100+100+100 final.jpg");
?>
<img src="final.jpg"> <!-- no image -->
<img src="resized.jpg"> <!-- no image -->
<img src="<?php echo $src; ?>"> <!-- alright -->
文档指定以下内容:
IM can also download an image that is published on the 'world wide web' by specifying that images URL. This basically provides a 'http:' image coder, which is why it works.
链接:http://www.imagemagick.org/Usage/files/#read
我试着大量的代码片段在网上创建,无法弄清楚为什么不工作?我可以使用其他的东西来达到我的目的?
要小心你的$ _POST ['src']'&'exec'。 – Prisoner
我已经搜索了其他解决方案,但似乎并不适合我的需要,我知道... –