解码数据库中的图片

时间:2015-07-26 12:20:10

标签: python database image hex

在数据库中,我有一个名为0xFFD8FFE000104A46494600010101012C012C0000FFDB00430008060607060508070707... 的列,其中包含以下字符开头的字符:

%1

如何根据此数据制作图像?

(可以从here查看和下载完整的数据。)

1 个答案:

答案 0 :(得分:2)

您可以尝试沿着这些行('pict.txt'文件包含从您问题中的链接下载的十六进制数据):

findViewById()

运行它会显示以下图像:

image from data linked to in question

打开图像存储文件并创建import io from PIL import Image with open('pict.txt', 'rb') as img_file: img_file.read(2) # skip over the '0x' hex_data = img_file.read() binary_data = hex_data.decode('hex') memory_file = io.BytesIO(binary_data) img = Image.open(memory_file) img.show() PIL类的实例后,您可以访问其他图像属性,例如Imageimg.format,{{1根据需要等等(见Image Class Attributes)。