从firebas获取后如何显示图像

2024-03-29 14:22:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用python从firebase存储中获取图像到我的raspberry pi3中。你知道吗

    import urllib.request 
    URL=urllib.request.urlretrieve("https://firebasestorage.googleapis.com/v0/b/cameraviewer-32936.appspot.com/o/images%2F49567?alt=media&token=1eded9d0-b9f0-48bf-b869-37756b31a94a")

URL对象有几个键值对。其中一个是'str',值为:

'C:\Users\DELL\AppData\Local\Temp\tmp4ki4w7we'

上面的值代表图像的路径,但是我如何打开图像。我不知道该去哪里或者我很困惑。你知道吗


Tags: https图像importcomurlrequesturllibraspberry
1条回答
网友
1楼 · 发布于 2024-03-29 14:22:02

使用Python图像库(PIL)非常简单。PIL是一个免费的开源库。你知道吗

如何安装PIL

如果没有安装枕头,请首先打开终端(CTRL+ALT+t),然后使用命令下载:

sudo pip install Pillow

显示图像

成功安装后,请使用以下代码显示下载的图像:

from PIL import Image
import urllib.request 

URL=urllib.request.urlretrieve("https://firebasestorage.googleapis.com/v0/b/cameraviewer-32936.appspot.com/o/images%2F49567?alt=media&token=1eded9d0-b9f0-48bf-b869-37756b31a94a")
img = Image.open(URL[0])
img.show()

相关问题 更多 >