当前位置: 动力学知识库 > 问答 > 编程问答 >

django - Thumbnail Error The source file does not appear to be an image

问题描述:

I finally got a thumbnail error.

I'm using easy thumbnail

I have this code in my settings file

THUMBNAIL_ALIASES = {

'': {

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

},

}

In my post.html

 {% load thumbnail %}

<img src="{{post.image}}" />

<img src="{{ post.image|thumbnail_url:'avatar' }}" alt="" />

{% thumbnail post.image 300x200 %}

post.image works but below two thumbnails are not.

I have to say I'm glad I'm getting these errors, giving me starting point

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)

网友答案:

You should install the libraries required to support different image formats, then rebuild 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
分享给朋友:
您可能感兴趣的文章:
随机阅读: