2017-03-22 36 views
2

當我試圖從任何圖像生成縮略圖,出現此錯誤:Python的 - 枕頭創建縮略圖錯誤

TypeError: 'int' object has no attribute '__getitem__' 

命令:

./manage.py shell 
from PIL import Image 
i = Image.open('1.jpg') 
i.thumbnail(200) 

錯誤消息:

--------------------------------------------------------------------------- 
TypeError         Traceback (most recent call last) 
<ipython-input-6-3e0cd0330e45> in <module>() 
----> 1 i.thumbnail(200) 

/home/user/.virtualenvs/project/lib/python2.7/site-packages/PIL/Image.pyc 
in thumbnail(self, size, resample) 
    1828   # preserve aspect ratio 
    1829   x, y = self.size 
-> 1830   if x > size[0]: 
    1831    y = int(max(y * size[0]/x, 1)) 
    1832    x = int(size[0]) 

TypeError: 'int' object has no attribute '__getitem__' 

某處我讀了一些關於libjpeg包的內容,但是我得到了所有類型文件的錯誤(gif,png,...)

我使用的archlinux:

$ uname -a 
Linux chalist 4.9.11-1-ARCH # 1 SMP PREEMPT 
Sun Feb 19 13:45:52 UTC 2017 x86_64 GNU/Linux 

回答