Can I open an image inside a zip with PIL/Pillow without extracting it to disk first?
The recent Pillow releases do not require .seek()
:
#!/usr/bin/env python
import sys
from zipfile import ZipFile
from PIL import Image # $ pip install pillow
filename = sys.argv[1]
with ZipFile(filename) as archive:
for entry in archive.infolist():
with archive.open(entry) as file:
img = Image.open(file)
print(img.size, img.mode, len(img.getdata()))