Skip to main content

Python envelope for the popular C library libjpeg for handling JPEG files.

Project description

PyPI version Commit CI/CD Release CI/CD Documentation Status PyPI downloads Stars Contributors Wheel Status PyPi license Last commit

jpeglib

Python envelope for the popular C library libjpeg for handling JPEG files.

libjpeg offers full control over compression and decompression and exposes DCT coefficients and quantization tables.

Installation

Simply install the package with pip3

pip install jpeglib

or using the cloned repository

python setup.py install

:warning: This will install jpeglib together with multiple versions of libjpeg, libjpeg-turbo and mozjpeg. For common architectures/OS we provide prebuilt wheels, but installing from source takes couple of minutes.

Usage

Import the library in Python 3

import jpeglib

DCT

Get discrete cosine transform (DCT) coefficients and quantization matrices as numpy array

im = jpeglib.read_dct('input.jpeg')
im.Y; im.Cb; im.Cr; im.qt

You get luminance DCT, chrominance DCT and quantization tables.

Write the DCT coefficients back to a file with

im.write_dct('output.jpeg')

Pixel data

Decompress the input.jpeg into spatial representation in numpy array with

im = jpeglib.read_spatial('input.jpeg')
im.spatial

You can specify parameters such as output color space, DCT method, dithering, etc.

Write spatial representation in numpy arrray back to file with

im.write_spatial('output.jpeg')

You can specify input color space, DCT method, sampling factor, output quality, smoothing factor etc.

You can find all the details in the documentation.

libjpeg version

It is possible to choose, which version of libjpeg should be used.

jpeglib.version.set('6b')

Currently jpeglib supports all versions of libjpeg from 6b to 9e, libjpeg-turbo 2.1.0 and mozjpeg 4.0.3. Their source codes is baked inside the package and thus distributed with it, avoiding external dependency.

Get currently used libjpeg version by

version = jpeglib.version.get()

You can also set a libjpeg version for a scope only.

jpeglib.version.set('6b')
im = jpeglib.read_spatial('image.jpeg') # using 6b
with jpeglib.version('9e'):
    im = jpeglib.read_spatial('image.jpeg') # using 9e
im = jpeglib.read_spatial('image.jpeg') # using 6b again

Credits

Developed by Martin Benes, University of Innsbruck, 2023.

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jpeglib-1.0.1.tar.gz (5.7 MB view details)

Uploaded Source

Built Distributions

jpeglib-1.0.1-cp38-abi3-win_amd64.whl (9.8 MB view details)

Uploaded CPython 3.8+ Windows x86-64

jpeglib-1.0.1-cp38-abi3-win32.whl (9.4 MB view details)

Uploaded CPython 3.8+ Windows x86

jpeglib-1.0.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.7 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

jpeglib-1.0.1-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (22.2 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.12+ i686 manylinux: glibc 2.17+ i686

jpeglib-1.0.1-cp38-abi3-macosx_11_0_arm64.whl (10.5 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

jpeglib-1.0.1-cp38-abi3-macosx_10_9_x86_64.whl (10.6 MB view details)

Uploaded CPython 3.8+ macOS 10.9+ x86-64

jpeglib-1.0.1-cp38-abi3-macosx_10_9_universal2.whl (14.3 MB view details)

Uploaded CPython 3.8+ macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file jpeglib-1.0.1.tar.gz.

File metadata

  • Download URL: jpeglib-1.0.1.tar.gz
  • Upload date:
  • Size: 5.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.20

File hashes

Hashes for jpeglib-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3f6311b813b1df7342a865c278eeafbac9ccca41134200da7863dce74c36f384
MD5 d68d6ebb4eabeb295baf54781f8c14aa
BLAKE2b-256 a994c90609243ad227fd96d61262f0e54662c4fb6a46c1a997d7187b205bf961

See more details on using hashes here.

File details

Details for the file jpeglib-1.0.1-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: jpeglib-1.0.1-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 9.8 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.20

File hashes

Hashes for jpeglib-1.0.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0af1298258df10be186a31031cf49cc4ddbed2bb8bbda0d39ad99f207c6484bb
MD5 9c24ce034e9cf1c48be657f2b133b8ba
BLAKE2b-256 dc6063fbb88750dcb9fb3f497fc62446661b209d335e32e3541a29d0d98c154d

See more details on using hashes here.

File details

Details for the file jpeglib-1.0.1-cp38-abi3-win32.whl.

File metadata

  • Download URL: jpeglib-1.0.1-cp38-abi3-win32.whl
  • Upload date:
  • Size: 9.4 MB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.20

File hashes

Hashes for jpeglib-1.0.1-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 fc8d0231f76ab9599e2d27d18356c2c1298f91e31bae2e72221993d766c0e914
MD5 401fadfd0ae7fc7dd740c5d548be3a66
BLAKE2b-256 9d6916a043d5ac5675f0e807d25028b295ce9867543f3b40252a9d0a182085d3

See more details on using hashes here.

File details

Details for the file jpeglib-1.0.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for jpeglib-1.0.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 00ba8a57f4fce30f969ca3cdf7988fc079d7ed32da83f63355a8a29abba635c1
MD5 96dac59a73046ba484a283d3168d743f
BLAKE2b-256 0b846e665e5c021419102629f17420cda45343e88859f9bdd40bc69d2b786a88

See more details on using hashes here.

File details

Details for the file jpeglib-1.0.1-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for jpeglib-1.0.1-cp38-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 97ace7371ded5aa710986061aa6fe5364175efa642e94ee1a75993fa8ab9607b
MD5 78dd93649263521d9417c245e5b566ba
BLAKE2b-256 86fda83edf190ac93bdcd8837c8d437f6c5b357e46daa846558a6798efe1ec5e

See more details on using hashes here.

File details

Details for the file jpeglib-1.0.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for jpeglib-1.0.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46867f31a161c44200fdc6ed87345fb322669131c49bdfc6aad836329a1bea20
MD5 a98c7a4f73b191d2f325786d9b4fd2e9
BLAKE2b-256 509d97a4a7156805ee28e6086dbd4ed663ba60e1a66704f1ca341caea3128173

See more details on using hashes here.

File details

Details for the file jpeglib-1.0.1-cp38-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for jpeglib-1.0.1-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b00942be30803b08ec741cd255f9ef887cfe2f04a0a47bb1b0648bce7de1430b
MD5 3198cff9ec551e4cce8710fc1dc9c933
BLAKE2b-256 3fd659150a6546f161a224ea9e364d6e7fc313a221cc3b38470694052950a0a2

See more details on using hashes here.

File details

Details for the file jpeglib-1.0.1-cp38-abi3-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for jpeglib-1.0.1-cp38-abi3-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 9c75047075b3c4a9a72ceeaffdc411a2d54de20b75c560384d68ad611548f441
MD5 ec7b5123419cc80d6e158ae638d7bc1a
BLAKE2b-256 2966f0e71a64c0a9c10484f334a307aa397a2ba9a7e2896e8bfd75d21ac8df02

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page