我收到错误“PIL.UnidentifiedImageError:无法识别位于 0x000001FFA78D10E0> 处的图像文件 <_io.BytesIO 对象””将字节转换为 img 时
我正在尝试将 2 字节数组合并在一起,并将所有字节转换回图像。但是,我不断收到问题“open raise UnidentifiedImageError(PIL.UnidentifiedImageError:无法识别0x000001FFA78D10E0处的图像文件<_io.BytesIO对象>”
from email.mime import base
import io
import base64
from PIL import Image
from numpy import byte
from array import array
compressedIm = Image.open(r"C:\Users\Student\Documents\Disso\Compressed_gabieureka.jpg")
compressedIm_resize = compressedIm.resize((500, 500))
buf = io.BytesIO()
compressedIm_resize.save(buf, format='JPEG')
byte_compressedIm = buf.getvalue()
Im2 = Image.open(r"C:\Users\Student\Documents\Disso\Photos\votetemi.jpg")
Im2_resize = Im2.resize((500, 500))
buf2 = io.BytesIO()
Im2_resize.save(buf2, format='JPEG')
byte_Im2 = buf2.getvalue()
bytearray1 = bytearray(byte_compressedIm)
bytearray2 = bytearray(byte_Im2)
mergedBytearray = bytearray1 + bytearray2
b = base64.b64decode(mergedBytearray)
image = Image.open(io.BytesIO(b))
image.show()
image.save("TheirDate", "PNG")
有人有解决方案或者可以在我的代码中发现明显的错误吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论