I'm using sorl thumbnail with Django. On my local setup it works
fine, but in production the thumbnails are not made.
My code looks like this:
{% load thumbnail %}
{% thumbnail up.image "32x32" crop="center" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% empty %}
<img src="{{ MEDIA_URL }}/images/missing_small.png" alt="" title="" />
{% endthumbnail %}
I enabled logging and the trace looks like this:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py",
line 45, in render
return self._render(context)
File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/templatetags/thumbnail.py",
line 97, in _render
file_, geometry, **options
File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/base.py",
line 49, in get_thumbnail
thumbnail)
File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/base.py",
line 74, in _create_thumbnail
image = default.engine.create(source_image, geometry, options)
File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/engines/base.py",
line 14, in create
image = self.colorspace(image, geometry, options)
File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/engines/base.py",
line 24, in colorspace
return self._colorspace(image, colorspace)
File "/usr/local/lib/python2.6/dist-packages/sorl_thumbnail-11.05.2-py2.6.egg/sorl/thumbnail/engines/pil_engine.py",
line 33, in _colorspace
return image.convert('RGB')
File "/usr/local/lib/python2.6/dist-packages/PIL/Image.py", line 679,
in convert
self.load()
File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
215, in load
raise_ioerror(e)
File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
52, in raise_ioerror
raise IOError(message + " when reading image file")
IOError: broken data stream when reading image file
The error isn't very helpful since the file is there and is readable
by all. I'm not sure how to get a more explicit error, or what to try
and fix. Stuck.
Thanks,
--
Greg Donald
destiney.com | gregdonald.com
And then more baffling is the fact that it works using `manage.py shell`
In [1]: from sorl.thumbnail import get_thumbnail
In [2]: im = get_thumbnail('/myproject/static/images/user_profiles/1/11-20-2010-2_5.jpg',
'32x32', crop='center' )
In [3]: im
Out[3]: <sorl.thumbnail.images.ImageFile object at 0x29fe090>
In [4]: im.url
Out[4]: 'http://example.com/cache/ff/31/ff318b4a995ff345d1d48e79b67ec62b.jpg'
It made the thumbnail, just won't make one via the template code.
My cache is clean, this is a new app. My key/value table is empty,
and my cache directory is empty and writable.
> There are data caches that
> you can clear with Sorl's custom management commands and disk caches
> that you can delete.
>
> Also make sure that you're passing valid parameters -- i.e. that
> up.image is an ImageField.
It is, it's a sorl thumbnail ImageField to be exact.
--
Your eyes are weary from staring at the CRT. You feel sleepy. Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. You cannot imagine why you ever felt
otherwise.
Yes, as I stated in a previous post, my entire application is chown'd
to my web server user and group 'www-data'. Every directory down to
and including my cache directory is fully readable and writable by
all.
It doesn't say it's a permissions error is the thing, just that the
stream is broken. Meanwhile I can create a thumbnail easily using
`manage.py shell`. From that I know sorl thumbnail has all the
required libraries installed and my uploaded image is not corrupt.
The only thing left is permissions, and they are as open as they can
be.
easy-thumbnail
--
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/