(für Python 3)
Wenn das Bild als Binärdatei gespeichert ist, öffnet sie direkt:
import PIL
# Create Image object
picture = PIL.Image.open('picture_code.dat')
#display image
picture.show()
# print whether JPEG, PNG, etc.
print(picture.format)
Wenn das Bild als Hex in einer Klartextdatei gespeichert wird picture_code.dat
ähnlich zu Ihre Google Docs-Link, muss es zuerst in binäre Daten umgewandelt werden:
import binascii
import PIL
import io
# Open plaintext file with hex
picture_hex = open('picture_code.dat').read()
# Convert hex to binary data
picture_bytes = binascii.unhexlify(picture_hex)
# Convert bytes to stream (file-like object in memory)
picture_stream = io.BytesIO(picture_bytes)
# Create Image object
picture = PIL.Image.open(picture_stream)
#display image
picture.show()
# print whether JPEG, PNG, etc.
print(picture.format)
Bitte fügen Sie weitere Informationen hinzu und was Sie bereits versucht haben. – ppasler
Es ist ein JPEG-Bild. (Durch Ausschluss - es ist kein PNG-Bild, wie aus der Kopfzeile ersichtlich ist.) – usr2564301