Posts Tagged ‘jpg’

jpegtran-cffi: fast JPEG transformations

January 25, 2014 Leave a comment

I haven’t tried it yet but it seems perfect for creating thumbnails for instance for a collection of images.

jpegtran-cffi has a very intuitive interface. Examples:

from jpegtran import JPEGImage
img = JPEGImage('image.jpg')

# Dimensions
print img.width, img.height  # "640 480"

# Transforming the image
img.scale(320, 240).save('scaled.jpg')
img.crop(0, 0, 100, 100).save('cropped.jpg')

# Transformations can be chained
data = (img.scale(320, 240)

It looks nice, worth checking out.

Python PIL : IOError: decoder jpeg not available

December 2, 2012 Leave a comment

Working with JPG files, PIL drops the following error:

Python PIL : IOError: decoder jpeg not available


sudo pip uninstall PIL
sudo apt-get install libjpeg8-dev
sudo pip install PIL

Found here.

Categories: python Tags: , , , ,