使用django + Pillow进行图片上传压缩格式保存时出错的处理

安装Pillow之前先安装好python-dev libzip-dev libjpeg8-dev libfreetype6-dev libpng12-dev 否则在用PIL(Pillow)进行上传图片压缩格式保存时会出错:
encoder jpeg not available
decoder zip not available
使用django + Pillow进行图片上传压缩格式保存时出错的处理_第1张图片

sudo apt-get install python-dev libzip-dev libjpeg8-dev libfreetype6-dev libpng12-dev
pip uninstall Pillow
pip install Pillow
安装好后的报告如下:

--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version Pillow 2.6.1
platform linux2 2.7.6 (default, Mar 22 2014, 22:59:38)
[GCC 4.8.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------

如果想更多的支持时(webp libtiff) sudo apt-get install python-dev libzip-dev libjpeg8-dev libfreetype6-dev libpng12-dev libtiff5-dev libwebp-dev

pip uninstall Pillow

pip install Pillow

………

--------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version      Pillow 2.7.0
platform     linux2 2.7.6 (default, Mar 22 2014, 22:59:56)
             [GCC 4.8.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
--- LIBTIFF support available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
--- WEBP support available
--- WEBPMUX support available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

你可能感兴趣的:(django,pillow)