"The file cannot be reopened" when used with Django imagekit
See original GitHub issueI’m using django-s3-storage along with django-imagekit, but there seems to be a problem with the way django-s3-storage opens files. It’s easy to reproduce, and I have a full django app and repro instructions for the issue, here: https://github.com/mgalgs/iktest
I was a bit thrown off for a while because django-s3-storage isn’t anywhere in the stack trace of the erroneous situation, but @scottmx81 figured out that the test app works fine with django-storages, or by monkey-patching pilkit.open_image
like so:
from pilkit.lib import Image
from pilkit import utils
def open_image(target):
try:
target.seek(0)
return Image.open(target)
except ValueError:
return Image.open(target.storage.open(target.name))
utils.open_image = open_image
With django-storages no monkey-patch is required…
/cc @scottmx81
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
"The file cannot be reopened." error from django-imagekit after ...
I'm using django-imagekit to generate a thumbnail on a Django model: class Book(models.Model): title = models.
Read more >Template ValueError - The file cannot be reopened. #369
I just tried to use imagekit on a project which stores media on s3, ... The file cannot be reopened. boto==2.39.0 Django==1.8.11 ...
Read more >django-imagekit - Read the Docs
ImageKit is a Django app for processing images. Need a thumbnail? A black-and-white version of a user-uploaded image? ImageKit will make them for...
Read more >Is it possible to update ImageSpecField with a source's new file path?
I have a Django model with a picture (ImageField) and then a thumbnail (ImageSpecField) that ... so this fails with a "The file...
Read more >I/O operation on closed file: Django Imagekit & Pillow-django
The Problem as it can be seen was happening because the file sent by imagekit could not be processed directly by PIL. So...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Heh, no worries, closing an issue is it’s own reward.
If nobody steps forth to claim it, maybe throw the money at a worthy charity.
Fix confirmed! Thank you!!!
If you’d like, feel free to reap this small bounty 😃.