JPEG libraries for Python
- Pillow is the default choice: open, resize, auto-orient and save JPEG with full control over quality, progressive mode and chroma subsampling; read and write Exif, keep the ICC profile. Uses libjpeg-turbo.
- OpenCV (
opencv-python) loads JPEG into NumPy arrays for computer vision and machine learning. Fast, applies the Exif orientation on load, but uses BGR channel order and doesn’t preserve metadata on save.
Other options: pyvips (MIT, libvips binding) is faster than Pillow and uses little memory for large images and batch thumbnails; simplejpeg (MIT) is a minimal libjpeg-turbo wrapper for decoding to NumPy; ExifRead (BSD-3) and piexif read Exif without loading the image.
- OpenCV OpenCV for Python reads and writes JPEG as NumPy arrays. How to load and save JPEG, set quality, progressive and subsampling, decode at reduced size.
- Pillow Pillow is the standard Python imaging library. How to open and save JPEG, set quality, progressive and subsampling, fix rotation from Exif, read Exif tags.