Utiliser jpegtran (
https://github.com/jbaiter/jpegtran-cffi)
"""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 jpegtran from the Independent JPEG Group's libjpeg library (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."""
sudo apt-get python-dev
sudo apt-get install libffi-dev
sudo apt-get install libjpeg8-dev
-> virtualenv
pip install --user jpegtran-cffi