Tore thumbnail + django issues in production

I am using Sorl thumbnail with Django. It works fine on my local setup, but no thumbnails are created during the production process.

My code is as follows:

{% 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 turned on logging, and the trace looks like this:

Traceback (most recent call last):

[...]

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 does not help much, since the file is and is readable by everyone. I am not sure how to get a more obvious error, or what to try and fix.

And then even more perplexing is the fact that it works with 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'

He made a thumbnail, he just won’t make it using the template code.

Is anyone

+3
source share
4 answers

. Linux. Ubuntu 10.04, , 11.04, 11.10 ..

+1

, , - THUMBNAIL_ENGINE .

. , , , - . 3 : PIL ( ), Pgmagick ImageMagick/GraphicsMagick. .

, ​​ . , .

+4

syncdb?

, : python manage.py thumbnail cleanup

+2

: ligjpeg dev, 6.2. PIL. sorl.thumbnail PIL-1.1.7 virtualenv pip, PIL libjpeg6.2.

:

mantain - PIL, libjpeg sorl - - . PIL1.1.7, libjpeg6.2 sorl.thumbnail 11.9

( , virtualenv. , ):

yum erase python-imaging

oh wait, easy_install, PIL :

easy_install -mxN PIL
rm -rf  /usr/lib/python2.6/site-packages/PIL /usr/lib/python2.6/site-packages/PIL.pth

PIL virtualenv

pip uninstall PIL

, - virtualenv build, pip

rm -rf /path/to/virtualenv/build/PIL/

libjpeg, ... , ,

apt-get remove libjpeg8 libjpeg8-dev

... . , , libjpeg, . , PIL libjpeg. , , libjpeg8, - , .

libjpeg7 libjpeg8 dev ( , 6.2 - eh?), libjpeg7 libjpeg8, ./configure, ./make uninstall. /usr/local/lib/ libs, rm /usr/local/lib/libjpeg*.

, , , .

, PIL libjpeg.

...

yum install libjpeg-devel 

CentOS, 6.2, PIL1.1.7. Debian/Ubuntu

apt-get install libjpeg62-dev

pip install PIL sorl-thumbnail

restart the web server. happiness.

+2
source

All Articles