Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Python image processing library (PIL) to install and simple to use     - How to Check notebook CPU temperature in Ubuntu (Linux)

- Java NIO The Glob mode Detailed (Programming)

- How to Set Free SSH password on CentOS / RHEL (Linux)

- Linux non-root user uses less than 1024 ports (Linux)

- Eclipse improve the efficiency of good habits (Programming)

- How to install Docker and basic usage on Ubuntu 15.04 (Server)

- Python-- for anomalies and reflection of objects articles (Programming)

- Linux gprof oprofiling and performance testing tools (Linux)

- Hadoop 1 and 2.x installation notes (Server)

- A brief introduction to some important Docker commands (Server)

- Hutchison DG standby database CPU consumption reached bottleneck repair (Database)

- ARM runtime environment built from scratch using QEMU emulator (Linux)

- Linux firewall settings -DNS server articles (Server)

- Can not empty the Recycle Bin to repair problems in Ubuntu 14.04 (Linux)

- Java, extends and implements Usage (Programming)

- Java thread pool: ExecutorService, Executors (Programming)

- ctop: monitor container performance Linux command line artifact (Linux)

- Java polymorphism and exception handling (Programming)

- CentOS source installation GitLab Chinese Version (Server)

- JavaScript file loader LABjs API Explanation (Programming)

 
         
  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:      
 
- HDFS Hadoop Distributed File System Works (Server)
- Linux compiler of GCC (Linux)
- Android custom slideshow menu slidmenu (Programming)
- Let Markdown code syntax highlighting and support Django1.6 (Linux)
- Use the top command (Linux)
- Cobbler remotely install CentOS system (Linux)
- Oracle 12CIN-memory in table spaces (Database)
- Python system default encoding (Programming)
- Installation GitLab appears ruby_block supervise_redis_sleep action run (Linux)
- Expand an existing RAID arrays and remove the failed disk in a RAID (Linux)
- Python substring format (Programming)
- Linux --- process handle limit summary (Linux)
- iOS in the event delivery and the responder chain (Programming)
- Ubuntu 12.04 installed OpenCV 2.3.1, binary image (Linux)
- Setting the RedHat9 Intrusion Detection System (Linux)
- Ubuntu installed Komodo editor by PPA (Linux)
- Linux file content inspection - cat, tac, no, more, less, head, tail, od (Linux)
- How to install the Ruby runtime environment on Mac OS X (Linux)
- CentOS 6.6 command-line automatic completion (Linux)
- Oracle set the timer task JOB scheduler to execute stored procedures or PL / SQL code block (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.