Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Gravatar返回错误的文件扩展名_Php_Gravatar - Fatal编程技术网

Php Gravatar返回错误的文件扩展名

Php Gravatar返回错误的文件扩展名,php,gravatar,Php,Gravatar,我试图通过在散列的末尾添加.JPG来从Gravatar获取JPG图像,如下所示: 但是,如果我像这样将其保存到磁盘: file_put_contents($path, file_get_contents('https://www.gravatar.com/avatar/00000000000000000000000000000000.jpg?d=wavatar&f=y')); 或者,如果我把它直接从浏览器保存到我的计算机上,我会注意到这个文件实际上是一个PNG图像 为什么会这样? 我

我试图通过在散列的末尾添加.JPG来从Gravatar获取JPG图像,如下所示:

但是,如果我像这样将其保存到磁盘:

file_put_contents($path, file_get_contents('https://www.gravatar.com/avatar/00000000000000000000000000000000.jpg?d=wavatar&f=y'));
或者,如果我把它直接从浏览器保存到我的计算机上,我会注意到这个文件实际上是一个PNG图像

为什么会这样?
我错过什么了吗


太棒了

该链接将为您提供png文件,即使最后有jpg。如果您想要jpeg图像,请在php中尝试

echo '<img src="https://www.gravatar.com/avatar/'. md5(strtolower("myemail@gmail.com")).'"
class="img-circle" alt="User Image">';
echo';

请点击并下载代码。

Oh。。。好的,这就是API给出的全部内容。那么,为什么不使用gd将其转换为JPG呢?