import pickle
from io import BytesIO
from PIL import Image
im = Image.open("anyimage.jpg")
p = pickle.dumps(im)
im = pickle.loads(p)
# Fails in 11.2, works in 11.1
output = BytesIO()
im.save(output, format=im.format, quality="keep")
The code above to work.
Traceback (most recent call last):
File "test.py", line 14, in <module>
im.save(output, format=im.format, quality="keep")
File "/local/lib64/python3.9/site-packages/PIL/Image.py", line 2546, in save
if isinstance(self, ImageFile.ImageFile) and filename == self.filename:
File "/local/lib64/python3.9/site-packages/PIL/JpegImagePlugin.py", line 400, in __getattr__
raise AttributeError(name)
AttributeError: filename
It looks like something in Pillow 11.2 introduced an issue similar to this: #8472. This time with the
filenameattribute.What did you do?
What did you expect to happen?
The code above to work.
What actually happened?
What are your OS, Python and Pillow versions?