Nugroho's blog.: JPEG Support for Python 2.7's PIL Module on OS X Lion

Saturday, December 17, 2011

JPEG Support for Python 2.7's PIL Module on OS X Lion

My PIL module refuse to process jpeg image. It says that there is no decoder jpeg on my system. It's no good  since I want to process that kind of file using PIL in future, and my older iPhoto picture on my 13 inch MacBook Pro is generally in jpeg format too.

Here the snapshot


Nugrohos-MacBook-Pro:olah gambar nugroho$ python olahgambar.py 
Program Image Enchancement
Oleh Nugroho Adi Pramono
275514
===========================
format awal: JPEG 2448x3264 RGB
konversi ke grayscale
Traceback (most recent call last):
File "olahgambar.py", line 14, in
gbw = gb.convert("L")
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/Image.py", line 679, in convert
self.load()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/ImageFile.py", line 189, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/Image.py", line 385, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available
Nugrohos-MacBook-Pro:olah gambar nugroho$

So I googling for it and found libjpeg at http://www.ijg.org/files/, download, exctract and install it using magic UNIX words ./configure, make, make install

Nugrohos-MacBook-Pro:~ nugroho$ cd Downloads/jpeg-8c/
Nugrohos-MacBook-Pro:jpeg-8c nugroho$ ./configure
Nugrohos-MacBook-Pro:jpeg-8c nugroho$ make
Nugrohos-MacBook-Pro:jpeg-8c nugroho$ make test
rm -f testout*
./djpeg -dct int -ppm -outfile testout.ppm ./testorig.jpg
./djpeg -dct int -bmp -colors 256 -outfile testout.bmp ./testorig.jpg
./cjpeg -dct int -outfile testout.jpg ./testimg.ppm
./djpeg -dct int -ppm -outfile testoutp.ppm ./testprog.jpg
./cjpeg -dct int -progressive -opt -outfile testoutp.jpg ./testimg.ppm
./jpegtran -outfile testoutt.jpg ./testprog.jpg
cmp ./testimg.ppm testout.ppm
cmp ./testimg.bmp testout.bmp
cmp ./testimg.jpg testout.jpg
cmp ./testimg.ppm testoutp.ppm
cmp ./testimgp.jpg testoutp.jpg
cmp ./testorig.jpg testoutt.jpg
Nugrohos-MacBook-Pro:jpeg-8c nugroho$ sudo make install

reinstall PIL

PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform darwin 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support 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.

No comments:

323f (5) amp (1) android (12) apple (7) arduino (18) art (1) assembler (21) astina (4) ATTiny (23) blackberry (4) camera (3) canon (2) cerita (2) computer (106) crazyness (11) debian (1) delphi (39) diary (286) flash (8) fortran (6) freebsd (6) google apps script (8) guitar (2) HTML5 (10) IFTTT (7) Instagram (7) internet (12) iOS (5) iPad (6) iPhone (5) java (1) javascript (1) keynote (2) LaTeX (6) lazarus (1) linux (29) lion (15) mac (28) macbook air (8) macbook pro (3) macOS (1) Math (3) mathematica (1) maverick (6) mazda (4) microcontroler (35) mountain lion (2) music (37) netbook (1) nugnux (6) os x (36) php (1) Physicist (29) Picture (3) programming (189) Python (109) S2 (13) software (7) Soliloquy (125) Ubuntu (5) unix (4) Video (8) wayang (3) yosemite (3)