Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Python image processing library (PIL) to install and simple to use     - Linux User Management (Linux)

- Shell Scripting Interview Questions (Programming)

- How to find an IP address through the command line (Linux)

- Linux group account deletion, and other related operations (Linux)

- Linux Telnet access Windows 7 configuration procedure (Linux)

- Python interview must look at 15 questions (Programming)

- LMMS 1.03 install on Ubuntu 14.04 (Linux)

- To use slay kill user processes (Linux)

- Linux Getting Started tutorial: Experience QEMU virtual machine articles (Linux)

- Replace element and non-replaced elements of learning (Programming)

- To setup the Swift language learning environment under linux (Linux)

- Ubuntu Gnome and Fedora 22 Gnome desktop, extended to achieve global menu (Linux)

- Ubuntu rights management common commands (Linux)

- Five useful commands to manage file types and system time in linux (Linux)

- Linux disk virtualization (Linux)

- Necessity in Java packages (Programming)

- Ubuntu manually set the DSL broadband connection (Linux)

- Linux / CentOS 7.0 installation and configuration under Tomcat 8.0 (Server)

- Tecplot Installation under Linux (Linux)

- Install the latest development version of Wine on RedHat and Debian-based systems (Linux)

 
         
  Python image processing library (PIL) to install and simple to use
     
  Add Date : 2017-08-31      
         
         
         
  In the Python runtime environment for the server to get such a mistake about the image processing program Times today:

NameError: global name 'Image' is not defined

import Image next, found that Python does not own image processing library, requires a separate installation ...... next check, Python commonly used image processing library called PIL, you can use pip install - so good in the first types pip install with virtualenv PIL.

Installation completed soon, so pleasant to refresh, waiting through the program, the results being given:

IOError: decoder jpeg not available

Under Google, and we found that by pip install PIL is not installed jpeg decoder ...... examination under the installation log, also has such a description:

-------------------------------------------------- ------------------
PIL 1.1.7 SETUP SUMMARY
-------------------------------------------------- ------------------
version 1.1.7
platform linux2 2.7.5 (default, Sep 18 2013, 09:53:07)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)]
-------------------------------------------------- ------------------
*** TKINTER support not available
*** JPEG support not available
*** ZLIB (PNG / ZIP) support not available
*** FREETYPE2 support not available
*** LITTLECMS support not available
-------------------------------------------------- ------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

JPEG support not available ...... jpg is not supported, this is the trouble Which will lead ......

So I had to manually install:

wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz

tar xvfz Imaging-1.1.7.tar.gz

After you download and unzip success, to extract the directory, find Imaging-1.1.7 / setup.py file, modify the following lines of code (default TCL_ROOT set to NONE, here to spread the system library path to the job):

TCL_ROOT = "/ usr / lib64 /"
JPEG_ROOT = "/ usr / lib64 /"
ZLIB_ROOT = "/ usr / lib64 /"
TIFF_ROOT = "/ usr / lib64 /"
FREETYPE_ROOT = "/ usr / lib64 /"
LCMS_ROOT = "/ usr / lib64 /"

Then check before installation:

python /root/nowamagic_venv/Imaging-1.1.7/setup.py build_ext -i

Check No problem, you can perform the installation:

python /root/nowamagic_venv/Imaging-1.1.7/setup.py install

Successful installation:

-------------------------------------------------- ------------------
PIL 1.1.7 SETUP SUMMARY
-------------------------------------------------- ------------------
version 1.1.7
platform linux2 2.7.5 (default, Sep 18 2013, 09:53:07)
              [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)]
-------------------------------------------------- ------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG / ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
-------------------------------------------------- ------------------

Jpg has now been supported, the program is successful, briefly record what process to facilitate newcomers. Incidentally, with a test program, using Tornado upload photos and generate thumbnails:

import time
import tempfile
import Image

class AsciiImageProcessHandler (tornado.web.RequestHandler):
    def post (self):

        if self.request.files:
            for f in self.request.files [ 'image']:
                rawname = f [ 'filename']
                dstname = str (int (time.time ())) + '.' + rawname.split ( '.'). pop ()
                thbname = "thumb _" + dstname

                self.write (dstname)

                tf = tempfile.NamedTemporaryFile ()
                tf.write (f [ 'body'])
                tf.seek (0)

                # Create normal file
                # Img = Image.open (src)
                img = Image.open (tf.name)
                img.thumbnail ((920,920), resample = 1)
                img.save ( "./ static / upload / asciiimg /" + dstname)

                # Create thumb file
                img.thumbnail ((100,100), resample = 1)
                img.save ( "./ static / upload / asciiimg_tn /" + thbname)
 
                tf.close ()
     
         
         
         
  More:      
 
- Oracle 11g can not export a variety of empty table solution (Database)
- VMware virtual machine to use bridged mode fast Internet access (Linux)
- Install Mac OS X 10.9 systems VMware10 (Linux)
- How to install and use the malware detection tool LMD and ClamAV antivirus engine on Linux (Linux)
- A brief introduction to some important Docker commands (Server)
- Linux System Getting Started tutorial: Ubuntu desktop using the command line to change the system proxy settings (Linux)
- CentOS cross compiler core Raspberry Pi 2 (Linux)
- Linux character device - user mode and kernel mode data transfer data (Linux)
- Use ISO document production OpenStack used CoreOS mirror (Linux)
- Virt Related Command Summary (Linux)
- Linux bash: scp: command not found the problem (Linux)
- Upgrading to MySQL 5.7.9 MySQL 5.6.23 (Database)
- SecureCRT remote connection Ubuntu fails to solve the case (Linux)
- Can not empty the Recycle Bin to repair problems in Ubuntu 14.04 (Linux)
- Developing a Web server yourself (Server)
- Preliminary understanding of SELinux security management (Linux)
- C ++ pointer two third memory model (Programming)
- C language macro definition #define Usage (Programming)
- Zabbix monitors the status of TCP connections (Server)
- Linux system started to learn: how to solve the xxx is not in the sudoers file error (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.