【问题标题】:Sorl Thumbnail with Django in Mac OSX 10.7.2在 Mac OSX 10.7.2 中使用 Django 的 Sorl Thumbnail
【发布时间】:2012-01-15 03:29:21
【问题描述】:

我安装了 PIL、jpeg-8c、freetype-2.4.5 和 sorl thumbnail。在我的项目中,我将 sorl.thumbnail 放在 settings.py 中。但是当我使用这个代码行时:

>>> from apps.news.models import Newtest
>>> im = get_thumbnail( Newtest.objects.all()[0].image.name, '60')

Newtest.objects.all()[0].image 是我项目中的一张图片。

错误是这样的:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sorl_thumbnail-11.09-py2.7.egg/sorl/thumbnail/shortcuts.py", line 8, in get_thumbnail
    return default.backend.get_thumbnail(file_, geometry_string, **options)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sorl_thumbnail-11.09-py2.7.egg/sorl/thumbnail/base.py", line 61, in get_thumbnail
    thumbnail)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sorl_thumbnail-11.09-py2.7.egg/sorl/thumbnail/base.py", line 86, in _create_thumbnail
    image = default.engine.create(source_image, geometry, options)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sorl_thumbnail-11.09-py2.7.egg/sorl/thumbnail/engines/base.py", line 16, in create
    image = self.colorspace(image, geometry, options)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sorl_thumbnail-11.09-py2.7.egg/sorl/thumbnail/engines/base.py", line 34, in colorspace
    return self._colorspace(image, colorspace)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sorl_thumbnail-11.09-py2.7.egg/sorl/thumbnail/engines/pil_engine.py", line 56, in _colorspace
    return image.convert('RGB')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/Image.py", line 679, in convert
    self.load()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/ImageFile.py", line 189, in load
    d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/Image.py", line 385, in _getdecoder
    raise IOError("decoder %s not available" % decoder_name)
IOError: decoder zip not available

有人知道这是为什么吗?

谢谢

【问题讨论】:

标签: django macos osx-lion thumbnails sorl-thumbnail


【解决方案1】:

好的,我已经解决了这个问题,我删除了 PIL 并安装了这个包 libjpeg-libpng,再次安装了 PIL 并升级了 PIL。

$ pip uninstall pil

安装包

$ pip install pil --upgrade

【讨论】:

    猜你喜欢
    • 2012-06-21
    • 2012-11-22
    • 2013-01-30
    • 2012-11-29
    • 2016-05-09
    • 2011-05-13
    • 2012-09-05
    • 2012-08-26
    • 2011-09-12
    相关资源
    最近更新 更多