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,...)
についてこのエラーが出た。
Iは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
:/私のミス、TNX – Chalist