What did you do?
Using Pillow 10.0.1 and above, saving an image as a JPEG does not always result in the same number of bytes being written.
What did you expect to happen?
Saving the same image multiple times as a JPEG would result in files of the same size.
What actually happened?
The file sizes differ
What are your OS, Python and Pillow versions?
- OS: macOS Ventura 13.6
- Python: 3.9.6
- Pillow: 10.0.1
from io import BytesIO
from PIL import Image
image = Image.new(mode="RGB", size=(1024, 1024), color="red")
for _ in range(10):
output = BytesIO()
image.save(output, format="jpeg")
output.seek(0)
print(len(output.read()))
Actual Output:
17013
17014
17014
17014
17014
17013
17013
17014
17014
17014
Expected output:
The number of bytes should be the same for each iteration.