我知道我可以使用以下方法保存图像:
$input = 'http://images.websnapr.com/?size=size&key=Y64Q44QLt12u&url=http://google.com';
$output = 'google.com.jpg'; // << How to save the image with proper extension?
file_put_contents($output, file_get_contents($input));
但是如果我不知道下载图像的格式怎么办?如果它是“png”怎么办?在保存之前如何确定目标图像的类型?