Posts Tagged ‘image resize’

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.