The previous time item needs to have some picture to draw water to print, uses the Python PIL library, this article takes Imaging-1.1.7 as an example, records the source code compilation/Installation step of the PIL library.
PIL full name Python Image Library. It supports the processing of a variety of image formats, enabling our applications to proxy powerful image processing capabilities such as cropping, rotating, water-stamping, etc.
Download the v1.1.7 version number from the official website source code and unzip, CD to unzip the folder, read the README. If you want to work with JPEG pictures in your app. The JPEG library needs to be pre-installed. Otherwise, the error will be used .
1. Compiling and installing the JPEG library
1.1 Compiling the source code
Download the JPEG source code for the stable version number from the JPEG library website (the latest stable version is v9a) and unpack the source code GZ package. CD to unzip folder, VI to open the makefile file. Changes in 2 places:
1) Set the prefix variable to the installation target path of the JPEG library
2) Append-fpic to the Cflags setting (for the role of PIC, you can learn or see it through man gcc)
Note: since the installation of Imaging, you need to compile a _imaging.so library file, it is necessary to set-fpic parameters, otherwise Imaging compile will be reported such as the following error (if you want to verify, you can try-_-):
/USR/BIN/LD:/home/slvher/python-2.7.5/3rd-lib-src/jpeg-6b/lib/libjpeg.a (JCPARAM.O): Relocation R_X86_64_32 Against ' a local symbol ' can not is used when making a shared object; Recompile with-fpic/home/slvher/python-2.7.5/3rd-lib-src/jpeg-6b/lib/libjpeg.a:could not read Symbols:bad Valuecollect2:ld returned 1 exit Statuserror:command ' gcc ' failed with exit status 1
1.2 Install-lib
After compiling the JPEG source code with-FPIC parameters. Run such as the following command:
Make Installmake Install-lib
The above command installs the compiled JPEG library to the path specified by prefix (in fact from the source code folder CP file to the prefix folder)
2. Installing the Imaging Library
CD to Imaging-1.1.7,vi open setup.py. Change file:
1) stare out jpeg_root = None
2) Add jpeg_root = Libinclude ("/home/slvher/python-2.7.5/3rd-lib-src/jpeg-6b"), Save exit and run for example the following command:
Python setup.py build_ext-i
Under normal circumstances, imaging Library compilation will succeed
You can then install the PIL library into the Python site-packages folder by running the following command, for example:
Python setup.py Install
After that, the application will be able to use the Gil library properly.
"References"
1. PIL Official website
2. PiL Source Code Readme Document
"Python Notes" image processing library PIL source code installation steps