-
-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thumbnail tag failed error provides no details #461
Comments
For anyone finding this error message, I've also filed a bug with Pillow with this error in getting EXIF: |
@mariocesar Can you recommend a solution here? Some users upload images to my site which are corrupted somehow, and subsequently I get this error logging popping up all of the time.
|
@mariocesar Please. |
Yeah, please! =D |
The problem was in fact a bug in the watermarking program these users were using resulting in corrupt EXIF, and I worked with the author to get that fixed. The way I solved this issue was to always generate these thumbs in code (rather than template), and wrap in a try block. Additionally, I have a periodic process that tries to generate the thumbs rather than during the request cycle. If there's a problem with the image I log it with the necessary info, and remove the image so that the failure doesn't keep happening. def get_thumbnail(self, dims, upscale=False, **options):
""" Use sorl to produce the thumbnail; this also caches it for later.
"""
from sorl.thumbnail import get_thumbnail as sorl_get_thumbnail
try:
return sorl_get_thumbnail(self.best_image(), dims, upscale=upscale, **options)
except SyntaxError:
# Only catch SyntaxError: not a tiff, otherwise, I had Heroku rebooting
# and caused me to remove a good image.
log.error("Problem generating thumbnail for #%s @ %s. Removed it. %s",
self.id, dims, self.best_image().url, exc_info=True)
# Remove all images.
self.image = ""
self.save()
return None |
File "/app/.heroku/python/lib/python2.7/site-packages/sorl/thumbnail/engines/pil_engine.py", line 71, in _orientation `` python
why except (AttributeError, IOError, KeyError, IndexError) ? |
all right , they have already removed the bug.
|
Occasionally I get failures like this one but they provide no context as to which image failed making it difficult to debug when they are popping up occasionally on a busy web server. I don't know why this wouldn't have been included unless in this wrapper that details (such as the filename) was not available?
The text was updated successfully, but these errors were encountered: