Transfer from old version PiL to Pillow

Source: Internet
Author: User

To help new colleagues deploy the development environment, because the project code used in the PIL library processing pictures, resulting in some pictures in the browser can not display properly.
Several toss, solve the problem, here to record the issue of the newspaper, and Solutions:

1. Python version is not correct, 64-bit Python can not be installed, and can not be installed on the 32-bit PIL, so first change the PY to 32-bit version, this is the first to understand. No objection.

2. After installing PIL official compiled package, it will take place that the famous: the _IMAGINGFT C module is not installed, it is better to re-next at this time:
Address in http://www.lfd.uci.edu/~gohlke/pythonlibs/
Here are some third-party organizations compiled EXE package, to download the corresponding PY version of the PIL, re-install, it is best to download pillow, it is the PIL of some bug fixes after the compiled version
Before installing, you can first pip uninstall PiL

3. After installing the pillow, keyerror error may also occur, check the project source after the discovery is the image module of the Save function, processing picture file format times of the wrong.
Whether it's "JPEG" or "GIF", it will be an error, the solution is:
The project source in the import image, replaced by the from PIL import image.
According to this principle, all areas of the project that use the Image module should be replaced.


In addition, the Save Dictionary of the image can be tested in the CMD console,
>>> Import Image
>>> Image.init ()
1
>>> Image.SAVE.keys ()
[' XBM ', ' PCX ', ' SPIDER ', ' HDF5 ', ' TIFF ', ' BUFR ', ' EPS ', ' JPEG ', ' MSP ', ' GRIB ', '
GIF ', ' BMP ', ' TGA ', ' IM ', ' PPM ', ' PDF ', ' FITS ', ' PALM ', ' WMF ', ' PNG '

After the above test, if the Image.SAVE.keys () output is empty, then the SAVE format key is not found, and when the image is generated it will be reported Keyerror, the first line must be changed to: from PIL import Image

Transfer from old version PiL to Pillow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.