无法获取使用Image.open(requests.get())抓取的临时图像文件的文件扩展名

这是我在这里问的第一个问题,因此请原谅:-)

我有以下用于保存图像的文件,然后返回文件路径/ URL:

import os, requests
import secrets
from PIL import Image
from flask import url_for, current_app

def save_picture(google_url):
    random_hex = secrets.token_hex(8)
    i = Image.open(requests.get(google_url, stream=True).raw)
    f_ext = (i.format).lower()
    picture_fn = random_hex + f_ext
    picture_path = os.path.join(current_app.root_path, 'static/experience_images', picture_fn)

    output_size = (600, 600)
    i.thumbnail(output_size)
    i.show()
    i.save(picture_path)

    return picture_fn

我收到以下错误

引发ValueError(“未知的文件扩展名:{}”。format(ext))

The google_url parameter is a api URL to get an image from Google Places API. Below when I call i.show() the image opens up so I know the image is coming through, and I can see that in most cases (though not necessarily all) it is returning a PNG or JPEG file. I think the issue is that I'm not actually getting any filename from i, and I am assuming this is because it's a tempfile.

任何帮助将不胜感激,我是Python的新手。