python-pillow / python-pillow/Pillow
Can't save all extensions to BytesIO
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.8k
- Forks
- 2.5k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 89
Description
What did you do?
Try to automate testing all supported save formats.
What did you expect to happen?
Use the special needs of the specific extensions like BW of SGI only accepting mode L. (Why don't the plugins use Pillow to convert the mode themselves?)
What actually happened?
python -m doctest main.py
**********************************************************************
File "d:\code\image viewer\tk_image_viewer\main.py", line 1157, in main.test_save
Failed example:
test_save()
Exception raised:
Traceback (most recent call last):
File "C:\Users\C\AppData\Local\Python\pythoncore-3.13-64\Lib\doctest.py", line 1398, in __run
exec(compile(example.source, filename, "single",
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
compileflags, True), test.globs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<doctest main.test_save[0]>", line 1, in <module>
test_save()
~~~~~~~~~^^
File "d:\code\image viewer\tk_image_viewer\main.py", line 1163, in test_save
im.save(out, format=ext)
~~~~~~~^^^^^^^^^^^^^^^^^
File "D:\code\image viewer\tk_image_viewer\venv\Lib\site-packages\PIL\Image.py", line 2575, in save
save_handler = SAVE[format.upper()]
~~~~^^^^^^^^^^^^^^^^
KeyError: '.APNG'
**********************************************************************
1 item had failures:
1 of 1 in main.test_save
***Test Failed*** 1 failure.
What are your OS, Python and Pillow versions?
- OS: Windows 11
- Python: Python 3.13 (in active venv)
- Pillow: 12.1.0
Please paste here the output of running:
python3 -m PIL.report
--------------------------------------------------------------------
Pillow 12.1.0
Python 3.14.2 (tags/v3.14.2:df79316, Dec 5 2025, 17:18:21) [MSC v.1944 64 bit (AMD64)]
--------------------------------------------------------------------
Python executable is C:\Users\C\AppData\Local\Python\pythoncore-3.14-64\python.exe
System Python files loaded from C:\Users\C\AppData\Local\Python\pythoncore-3.14-64
--------------------------------------------------------------------
Python Pillow modules loaded from C:\Users\C\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\PIL
Binary Pillow modules loaded from C:\Users\C\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 12.1.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.14.1
--- LITTLECMS2 support ok, loaded 2.17
--- WEBP support ok, loaded 1.6.0
--- AVIF support ok, loaded 1.3.0
--- JPEG support ok, compiled for libjpeg-turbo 3.1.3
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.4
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1.zlib-ng, compiled for zlib-ng 2.3.2
--- LIBTIFF support ok, loaded 4.7.1
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
*** XCB (X protocol) support not installed
--------------------------------------------------------------------
python -m PIL.report
--------------------------------------------------------------------
Pillow 12.1.0
Python 3.13.12 (tags/v3.13.12:1cbe481, Feb 3 2026, 18:22:25) [MSC v.1944 64 bit (AMD64)]
--------------------------------------------------------------------
Python executable is D:\code\image viewer\tk_image_viewer\venv\Scripts\python.exe
Environment Python files loaded from D:\code\image viewer\tk_image_viewer\venv
System Python files loaded from C:\Users\C\AppData\Local\Python\pythoncore-3.13-64
--------------------------------------------------------------------
Python Pillow modules loaded from D:\code\image viewer\tk_image_viewer\venv\Lib\site-packages\PIL
Binary Pillow modules loaded from D:\code\image viewer\tk_image_viewer\venv\Lib\site-packages\PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 12.1.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.14.1
--- LITTLECMS2 support ok, loaded 2.17
--- WEBP support ok, loaded 1.6.0
--- AVIF support ok, loaded 1.3.0
--- JPEG support ok, compiled for libjpeg-turbo 3.1.3
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.4
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1.zlib-ng, compiled for zlib-ng 2.3.2
--- LIBTIFF support ok, loaded 4.7.1
--- RAQM (Bidirectional Text) support ok, loaded 0.10.3, fribidi 1.0.13, harfbuzz 12.3.0
*** LIBIMAGEQUANT (Quantization method) support not installed
*** XCB (X protocol) support not installed
--------------------------------------------------------------------
#TIL venv doesn't override "python3" as command. Sad.
from io import BytesIO
from PIL import Image
im = Image.open("eye.gif")
out = BytesIO()
for ext in ("APNG", "BW"):
im.save(out, ext)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The minimal reproduction calls PIL.Image.save with a BytesIO for APNG and BW; start there and inspect the format registration and save paths involved. Re-run the snippet across the listed extensions, with attention to BW's mode requirement, and define done as consistent handling of supported formats or clear errors for unsupported combinations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100