easy-thumbnails: InvalidImageFormatError: The source file does not appear to be an image
I’m getting the following error when trying to output a thumbnail in my Django template:
InvalidImageFormatError at /search/
The source file does not appear to be an image
This is happening with both JPEGs and PNGs. Here’s how my template looks:
{% load thumbnail %}
{% thumbnail profile.profile_photo 220x160 %}
I have THUMBNAIL_DEBUG = True in my settings file and easy_thumbnails added to my installed apps.
In my requirements.txt:
Pillow==2.2.1
easy-thumbnails==1.4
And before people say I don’t have png/jpeg support with Pillow/PIL here’s a pip install -r requirements.txt:
Installing collected packages: PIL
Running setup.py develop for PIL
--------------------------------------------------------------------
PIL 1.2a0 SETUP SUMMARY
--------------------------------------------------------------------
version 1.2a0
platform Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
*** WEBP support not available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
To check the build, run the selftest.py script.
Creating /home/robbie/git/myproject/venv/lib/python2.7/site-packages/PIL.egg-link (link to .)
PIL 1.2a0 is already the active version in easy-install.pth
So JPEG and PNG support are available. I’m also able to access the uploaded image from the browser by pointing to it’s MEDIA_URL path. What gives?
edit: I also get the same error when trying to load a 3rd party image such as
{% thumbnail "http://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm" 160x160 %}
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 16 (3 by maintainers)
@robpodosek Any hints on solving this? I’m having the same issue right now.
I recently had a similar issue, and i thought I’d share how i resolved my issue. Easy thumbnails uses
easy_thumbnails.storage.ThumbnailFileSystemStorageas default storage set viaTHUMBNAIL_DEFAULT_STORAGE. This is usually fine during development and I change that for production. However during deployment if this value is not set properly the thumbnails will be generated using the defaultThumbnailFileSystemStoragestorage option however if you serve media files from a different location thumbnails cant locate the source files or thinks it has a thumbnail generated but cant find it , and throws the error. You can suppress this by setting THUMBNAIL_DEBUG to False while you diagnose the problem. if youve changed yourDEFAULT_FILE_STORAGEorSTATICFILES_STORAGEor have set the storages option on a model field, you might have to configureTHUMBNAIL_DEFAULT_STORAGEto find and serve the files properlyThis happens to me as well, and is taking down the entire site with 2m monthly views. There should be a fallback image to avoid error 500.
This error should be silenced. It breaks the entire page, if an image has some form of damage or is incorrect. Instead, you should display a warning text or something similar. But breaking the entire page is too much for a simple error like this…
@MaykelLlanes could you please send me that image (if you can/use my private email) and tell me how you upload and access it.
You are using a templatetag (
oscar_thumbnail) I’m not familiar with, how does that error look like, if you use the nativethumbnailtemplatetag provided with easy-thumbnails?