#5386 closed defect (fixed)
PIL.Image.save() need format parameter when using file object
| Reported by: | 宋文武 | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 0.9.0 |
| Component: | programming | Keywords: | |
| Cc: | Parent Tickets: |
Description
Hi! when upload a jpg file, I got:
[...]
File "...src/mediagoblin/mediagoblin/media_types/image/processing.py",
line 125, in resize_tool
quality, filter)
File "...src/mediagoblin/mediagoblin/media_types/image/processing.py",
line 81, in resize_image
resized.save(resized_file, quality=quality)
File "...lib/python3.4/site-packages/Pillow-3.0.0-py3.4-linux-x86_64.egg/PIL/Image.py", line 1649, in save
format = EXTENSION[ext]
KeyError: ''
[...]
According to https://pillow.readthedocs.org/en/3.0.x/reference/Image.html?highlight=save#PIL.Image.Image.save
when use file object instead of filename, the format parameter should always be used.
Attachments (2)
Change History (9)
by , 10 years ago
| Attachment: | 0001-Specify-the-format-when-save-the-resized-image.patch added |
|---|
comment:1 by , 10 years ago
| Status: | new → accepted |
|---|
comment:2 by , 10 years ago
| Status: | accepted → review |
|---|
by , 10 years ago
| Attachment: | 0001-Pass-filename-instead-of-file-object-when-calling-PI.patch added |
|---|
comment:3 by , 10 years ago
| Summary: | Specify the format when save the resized image → PIL.Image.save() need format parameter when using file object |
|---|
comment:4 by , 10 years ago
I meet another one in media_types/ascii/processing.py.
Instead of pass file object, we can pass filename and PIL will figure out the format itself.
New patch attached.
comment:5 by , 10 years ago
| Resolution: | → fixed |
|---|---|
| Status: | review → closed |
Okay, fine by me, if PIL can do just fine reading it on its own!
comment:6 by , 10 years ago
| Milestone: | → 0.8.2 |
|---|
comment:7 by , 10 years ago
| Milestone: | 0.8.2 → 0.9.0 |
|---|
All 0.8.2 tickets are being rolled over to 0.9.0

The modification looks good and is covered by the tests.
./runtests.sh --cov-report=term-missing --cov=mediagoblin mediagoblin/tests
mediagoblin/media_types/image/processing.py 190 65 66% 21-22, 71-72, 105-107, 137-151, 163-164, 245-246, 269, 282-307, 311, 337-342, 350-373, 377, 381-388, 398-404, 408-418, 422, 425-426, 436-446
Reviewed-by: Loic Dachary <loic@…>