Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

jpegtran-cffi

Build status

jpegtran-cffi is a Python package for fast JPEG transformations. Compared to other, more general purpose image processing libraries like wand-py or PIL/Pillow, transformations are generally more than twice as fast (see Benchmarks). In addition, all operations except for scaling are lossless, since the image is not being re-compressed in the process. This is due to the fact that all transformation operations work directly with the JPEG data.

This is achieved by using multiple C routines from the Enlightenment project’s epeg library (for scaling) and the turbojpeg library from the libjpeg-turbo project (for all other operations). These routines are called from Python through the CFFI module, i.e. no external processes are launched.

The package also includes rudimentary support for getting and setting the EXIF orientation tag, automatically transforming the image according to it and obtaining the JFIF thumbnail image.

jpegtran-cffi was developed as part of a web interface for the spreads project, where a large number of images from digital cameras had to be prepared for display by a Raspberry Pi. With the Pi’s rather slow ARMv6 processor, both Wand and PIL were too slow to be usable.

Requirements

  • CPython >=2.7 or >=3.5 or PyPy

  • cffi >= 1.0

  • libturbojpeg with headers

Installation

$ pip install jpegtran-cffi

Usage

from jpegtran import JPEGImage

img = JPEGImage('image.jpg')

# JPEGImage can also be initialized from a bytestring
blob = requests.get("http://example.com/image.jpg").content
from_blob = JPEGImage(blob=blob)

# Reading various image parameters
print img.width, img.height  # "640 480"
print img.exif_orientation  # "1" (= "normal")

# If present, the JFIF thumbnail can be obtained as a bytestring
thumb = img.exif_thumbnail

# Transforming the image
img.downscale(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.downscale(320, 240)
            .rotate(90)
            .flip('horizontal')
            .as_blob())

# jpegtran can transform the image automatically according to the EXIF
# orientation tag
photo = JPEGImage(blob=requests.get("http://example.com/photo.jpg").content)
print photo.exif_orientation  # "6" (= 270°)
print photo.width, photo.height # "4320 3240"
corrected = photo.exif_autotransform()
print corrected.exif_orientation  # "1" (= "normal")
print corrected.width, corrected.height  # "3240 4320"

For more details, refer to the API Reference.

Benchmarks

All operations were done on a 3.4GHz i7-3770 with 16GiB of RAM and a 7200rpm HDD with the following 2560x1920 8bit RGB JPEG:

http://upload.wikimedia.org/wikipedia/commons/8/82/Mandel_zoom_05_tail_part.jpg

https://jpegtran-cffi.readthedocs.io/en/latest/_images/benchmark.png

Both wand-py and PIL were run with the fastest scaling algorithm available, for wand-py this meant using Image.sample instead of Image.resize and for PIL the nearest-neighbour filter was used for the Image.resize call.

License

The MIT License (MIT)

Copyright (c) 2014 Johannes Baiter <johannes.baiter@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

Metadata

Release files for jpegtran-cffi-wheels 0.5.3.dev0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for jpegtran-cffi-wheels 0.5.3.dev0
File
jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-win32.whl CPython 3.11 CPython 3.11 Windows x86-32 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-musllinux_1_1_x86_64.whl CPython 3.11 CPython 3.11 Linux musl 1.1+ x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-win32.whl CPython 3.10 CPython 3.10 Windows x86-32 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-musllinux_1_1_x86_64.whl CPython 3.10 CPython 3.10 Linux musl 1.1+ x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-win32.whl CPython 3.9 CPython 3.9 Windows x86-32 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-musllinux_1_1_x86_64.whl CPython 3.9 CPython 3.9 Linux musl 1.1+ x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-musllinux_1_1_x86_64.whl CPython 3.8 CPython 3.8 Linux musl 1.1+ x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-musllinux_1_1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux musl 1.1+ x86-64 Details
jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details

Total release size: 13.4 MB

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-win_amd64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-win_amd64.whl
Size 617.9 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
69ff91595c0aa81bf64dbc4b145e5f128001de8aa92f3efbeecf612e81ed937e
BLAKE2b-256 checksum
How to use checksums
7f61651addd03e17de775099d338e5d8055077cc1b476020fbf00334bd9a3602
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-win32.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-win32.whl
Size 551.5 kB
Tags CPython 3.11 Windows x86-32
SHA-256 checksum
How to use checksums
41bb3c0edd4b8768c0586b874ab78384ef9d08a9372fb50e03e88f2a2298649a
BLAKE2b-256 checksum
How to use checksums
77d5b7aecde6210116868a7ef71b9baf28ff36a2e1903115552c04d5535efb1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-musllinux_1_1_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-musllinux_1_1_x86_64.whl
Size 719.3 kB
Tags CPython 3.11 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
72e11a9e1c7438581037d43014d47050d286ba8b711fba7bc4643f24443f1c70
BLAKE2b-256 checksum
How to use checksums
672bae2db7025d9010567296bd4b98d20de6efd4e81334dc6969e5504654ff19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 794.7 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
33a57387039e9f8b4d54384b05eeb7ff6c0ddf850d35846394aea13bcb52216c
BLAKE2b-256 checksum
How to use checksums
a907078f1fbc89c458a1dec42093d83d6a2b0d9c8cdc29fb7b2f9236edca8668
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-win_amd64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-win_amd64.whl
Size 617.9 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
34c016475431505cbcea9a136de21c6e79c5ea46173becf294c3fc42c37892c9
BLAKE2b-256 checksum
How to use checksums
b0b1437822a3a138ce5dc37823516b7235ae8a4d8ce1428a18e37db27f66ad8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-win32.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-win32.whl
Size 551.5 kB
Tags CPython 3.10 Windows x86-32
SHA-256 checksum
How to use checksums
add5425b6436e09d1b831f962a7c318ced7841d4a5a9c8fd843ba78b4364bf91
BLAKE2b-256 checksum
How to use checksums
65769439b0ff2d000972c3bbcdead57124aaa713dc8f9ec59bd05795f9e65b2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-musllinux_1_1_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-musllinux_1_1_x86_64.whl
Size 719.2 kB
Tags CPython 3.10 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
17e9781c04fd386b347452d83a1749b124468c76d9290bc3936336d680e10c40
BLAKE2b-256 checksum
How to use checksums
c406f4a50060f0c4062c6c437a4ed06728a8e5d37450bd3b17a4969bdbe4657f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 794.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e054470ab72d80869794dde8a2283aa09023053fb4ec4472078a83300ded93e1
BLAKE2b-256 checksum
How to use checksums
73aa6c9ea1f99651e52b0f51863281d67f1ad35abe2fc8e14a84a9daab76be3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-win_amd64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-win_amd64.whl
Size 618.6 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
deed127d7bb9135eadc4d6389a89427d317b04de3344028b8a77ab9e73153283
BLAKE2b-256 checksum
How to use checksums
5b7a873650fe1c1458a05ddaedb8dca88fa63f56a2ba10ba9371e0413b90b051
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-win32.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-win32.whl
Size 552.2 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
ff0ce3a266f66ab9a819a49c8b30ae5c39dfcaf40abd7e61440d386e24f26cbe
BLAKE2b-256 checksum
How to use checksums
5c304ca3c43614bee9480fab68b948abe56035c62f4760f8c20762368593fd75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-musllinux_1_1_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-musllinux_1_1_x86_64.whl
Size 719.3 kB
Tags CPython 3.9 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
e9fb7f33687b534c5fa426f3725fdd98248e50b26d2cbe2d5ee4e8dcfc6f4552
BLAKE2b-256 checksum
How to use checksums
996684a21e87efb8e823845200e5fd4a55f3543e4fa0bd19de53d74b3ac5b5a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 794.7 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
362494f617dba7b8837dc37bbe7ad83111f3252e54e2f45e9c6c5fca0b99d0e7
BLAKE2b-256 checksum
How to use checksums
3f6bbf742a3c3b6b879f06d85da17a4c1ef71d60d9fa34fad522c7e91e4ab27c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-win_amd64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-win_amd64.whl
Size 618.6 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
6f7ddbe6d3dd8ba20760eb8880bcd4b0a1453f3efdec67e8aa7c37af9d43d789
BLAKE2b-256 checksum
How to use checksums
43ca058433da09b260b7ffa09cfbdee4b3bd27377c1db14974464761ddef837e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-win32.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-win32.whl
Size 552.2 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
de0939f290994f917793029630ba9cfa985b51f5c84f7de7285d9599fa4eafc8
BLAKE2b-256 checksum
How to use checksums
538bcc615a4c1799b1b3058f2c74cda6ce413c42c8eb96f260eeec56d91ec588
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-musllinux_1_1_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-musllinux_1_1_x86_64.whl
Size 719.6 kB
Tags CPython 3.8 Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
4c3cbb40b613023b270cd08b394683bad2208cfc6fc420ac0d85e190f068ed34
BLAKE2b-256 checksum
How to use checksums
e175bc9f47d2bc7954f5593f76805948ce5f2db74709958591729affe84bd89e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 794.9 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
71a564be29d390e014f67742c42a489eb4124715f79a77d05e1d711eba772e1a
BLAKE2b-256 checksum
How to use checksums
acc7bd7b0fa50e030179a2620b36fa06358c08c1eac5b361fa48af5a782aa2ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-win_amd64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-win_amd64.whl
Size 618.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
cc85e09399711bfa51fc8709122461fbb40ee739af63bf59bd3c89ae5817626c
BLAKE2b-256 checksum
How to use checksums
f77cd809e363414cda93b7bfe0c9d6273b8e8ea00e717a8eba4d143f6e1a8aa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-win32.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-win32.whl
Size 552.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
a3f548d9350351a5ef9e42aa726532341481d6760c4244ddd3cb64a1db0acfea
BLAKE2b-256 checksum
How to use checksums
52b14f9af2ba2b5fb65195df52a70db7d74ab9b9fe84ccbf73cf927d62c277f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-musllinux_1_1_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-musllinux_1_1_x86_64.whl
Size 719.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux musl 1.1+ x86-64
SHA-256 checksum
How to use checksums
c43b4be9dd17c38067ccc452cb6a9b41af9ee15cde077ae15aebd0ad24cdc97e
BLAKE2b-256 checksum
How to use checksums
7a1c9a2d93db956b0c646ec45145c13d077bc98772263609f755c90f6616c8e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL jpegtran_cffi_wheels-0.5.3.dev0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 794.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
7277edf5c6b4b6cb23cae3fbc88e1d37089dc700a1d7a9daabdfd98e50ed1035
BLAKE2b-256 checksum
How to use checksums
54a8826f3d74cceade99640d7e307de90c0a104da2d8138afea683355cb9b0d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.5.3.dev0 This release

20 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page