Archive

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.rotate(90).save('rotated.jpg')
img.crop(0, 0, 100, 100).save('cropped.jpg')

# Transformations can be chained
data = (img.scale(320, 240)
            .rotate(90)
            .flip('horizontal')
            .as_blob())

It looks nice, worth checking out.

Python PIL : IOError: decoder jpeg not available

December 2, 2012 Leave a comment

Problem
Working with JPG files, PIL drops the following error:

Python PIL : IOError: decoder jpeg not available

Solution

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

Found here.

Categories: python Tags: , , , ,