在python3中,我有一个字节对象,比如
a = b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01\\x01\\x00`\\x00`\\x00\\x00\\xff\\xdb\\x00C\\x00\\x08\\x06\\x06\\x07\\x06\\x05\\x08\\x07\\x07\\x07\\t\\t\\x08\\n\\x0c\\x14\\r\\x0c\\x0b\\x0b\\x0c\\x19\\x12\\x13\\x0f\\x14\\x1d\\x1a\\x1f\\x1e\\x1d\\x1a\\x1c\\x1c $.\\\
更新在下面
有没有办法将PIL图像传递给谷歌云视觉?
我试着使用io.Bytes、io.String和Image.tobytes(),但我总是得到:
Traceback (most recent call last):
"C:\Users\...\vision_api.py", line 20, in get_text
image = vision.Image(content)
File "C:\...\venv\lib\site-packages\proto\message.py", line 494, in __init__
rais
在过去的几个小时里,我一直试图创建一个图像的Base64字符串,但是它不能工作。
ship_color = (0,100,100,255)
img = Image.new("RGBA", (100,100))
for i in range(20):
for j in range(20):
img.putpixel((40 + i, 40 + j), ship_color)
img.save("tmp.png", format = "PNG")
im = open("tmp.png", "rb")
我已经使用SQLite的DB浏览器将图像作为blob保存在SQLite数据库中。我想从数据库中打开blob数据,并在窗口中绘制图像。 为此,我这样做: import sqlite3
from PIL import Image, ImageTk
sql_fetch_blob_query = "SELECT * from credentials where id = ?"
c.execute(sql_fetch_blob_query, (id,))
record = c.fetchall()
for row in record:
print("Id =
我试图用Python打开一个PNG文件。我相信我有一个正确编码的PNG。
文件全文:
它的开头是:
\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR
并以以下内容结束:
\x00IEND\xaeB`\x82
到目前为止我的代码是:
import PIL.Image as Image
with open('./test_image_3.txt', 'rb') as f:
b = f.read()
b = base64.b64decode(b).decode("unicode_escape").encode(&
我正在调用js canvas.toDataURL();从那里将它发送到我的服务器,我想用boto3client发送它。假设变量中有数据,我如何在python中更改formate。
#image is a 10 by 10 red square can be displayed with adding data as src of a HTML image tag
data = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYV2P8z8AARIQB46hCfIFE/eABAGX