我正在尝试使用PHP下载this图像以使用GD进行编辑.我找到了许多图像链接解决方案,但这个是下载链接.
编辑:
$curl = curl_init("http://minecraft.net/skin/Notch.png");
$bin = curl_exec($curl);
curl_close($curl);
$img = @imagecreatefromstring($bin);
这是我目前的代码.它显示“301 Moved Permanently”.我必须设置CURLOPT吗?
解决方法:
$curl = curl_init("http://minecraft.net/skin/Notch.png");
// Moved? Fear not, we'll chase it!
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
// Because you want the result as a string
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$bin = curl_exec($curl);
curl_close($curl);
$img = @imagecreatefromstring($bin);