Python - image file is truncated (2 bytes not processed)
Python에서 PIL 라이브러리를 사용하여 이미지를 불러올 때, 이미지가 깨져있다면 image file is truncated (2 bytes not processed) 에러가 발생한다. 이 에러가 발생할 경우, ImageFile 관련 코드를 추가하면 해결 할 수 있다.
from PIL import Image, ImageFile
import matplotlib.pyplot as plt
ImageFile.LOAD_TRUNCATED_IMAGES = True
# image file is truncated (2 bytes not processed) 에러 발생시 위의 코드 추가
!wget https://i2.pickpik.com/photos/900/201/265/korea-seoul-jongno-city-preview.jpg
img = Image.open('korea-seoul-jongno-city-preview.jpg')
LOAD_TRUNCATED_IMAGES는 깨진 이미지로 불러올지에 대한 여부를 선택하는 변수이다. False로 하면 불러오지 않고 True로 하면 이미지를 불러올 수 있다.
참고 사이트:
https://stackoverflow.com/questions/12984426/pil-ioerror-image-file-truncated-with-big-images
PIL "IOError: image file truncated" with big images
I think this problem is not Zope-related. Nonetheless I'll explain what I'm trying to do: I'm using a PUT_factory in Zope to upload images to the ZODB per FTP. The uploaded image is saved as a Zope
stackoverflow.com
https://stackoverflow.com/questions/60584155/oserror-image-file-is-truncated
OSError: image file is truncated
When I am processing a bunch of images, on one of them I get this error File "/home/tensorflowpython/firstmodel/yololoss.py", line 153, in data_generator image, box = get_random_data(
stackoverflow.com