当前位置: 代码迷 >> 综合 >> 如何处理AttributeError: JpegImageFile object has no attribute shape
  详细解决方案

如何处理AttributeError: JpegImageFile object has no attribute shape

热度:37   发布时间:2023-10-18 13:31:44.0

AttributeError: ‘JpegImageFile’ object has no attribute ‘shape’

如何处理AttributeError: JpegImageFile object has no attribute shape
程序中由于是利用opencv 读取图片格式和PIL中Image 读取的图片格式差异问题导致的,解决方法就是在save操作之前,将图片的格式转化一下 ,将opencv 读取的图片转化成PIL Image 的格式。
转换方法:
opencv 转换成 PIL.Image:
Img= Image.fromarray(cv.cvtColor(Img,cv2.COLOR_BGR2RGB))

  相关解决方案