【问题标题】:Thumbnail Error The source file does not appear to be an image缩略图错误 源文件似乎不是图像
【发布时间】:2016-04-05 01:45:39
【问题描述】:

我终于遇到了缩略图错误。 我正在使用简单的缩略图 我的设置文件中有这段代码

THUMBNAIL_ALIASES = {
    '': {
        'avatar': {'size': (50, 50), 'crop': True},
    },


}

在我的 post.html 中

    {% load thumbnail %}
<img src="{{post.image}}" />
<img src="{{ post.image|thumbnail_url:'avatar' }}" alt="" />
        {% thumbnail post.image 300x200 %}

post.image 有效,但以下两个缩略图无效。 我不得不说我很高兴收到这些错误,这给了我起点

InvalidImageFormatError at /s/

The source file does not appear to be an image


class Post(models.Model):
    category = models.ForeignKey(Category)
    pub_date = models.DateTimeField(auto_now_add = True)
    title = models.CharField(max_length = 100)
    content = FroalaField()
    url = models.URLField(max_length=250, blank=True, null=True)
    moderator = models.ForeignKey(User)
    rank_score = models.FloatField(default= 1)
    views = models.IntegerField(default=0)
    image = models.ImageField(upload_to="images",blank=True, null=True)

【问题讨论】:

  • post 的模型定义是什么?这是第三方应用吗?
  • @Paulo 不,这不是第三方应用,我会上传我的模型
  • @Paulo heydoyouknow this?
  • 奇怪,你能发布你有哪个 django 和 easy-thumbnails 版本吗?同时发布您的简单缩略图设置(如果有别名除外)。
  • 我知道我从今天早上开始就一直在尝试这个,easy-thumbnails==2.3 我尝试像这里所说的那样更新枕头github.com/SmileyChris/easy-thumbnails/issues/169 但不起作用,我没有任何东西简单的缩略图,而不是张贴在那里的缩略图

标签: django thumbnails


【解决方案1】:

您应该安装支持不同图像格式所需的库,然后重建 Pillow:

sudo apt-get install libjpeg8 libjpeg8-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install liblcms1 liblcms1-dev

pip install Pillow

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-16
    • 1970-01-01
    • 1970-01-01
    • 2016-12-26
    • 2010-11-13
    • 2012-12-14
    • 2012-11-21
    相关资源
    最近更新 更多