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.2.tar.gz (5.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

jpeglib-1.0.2-cp38-abi3-win_amd64.whl (9.9 MB view details)

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

jpeglib-1.0.2-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (22.8 MB view details)

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

jpeglib-1.0.2-cp38-abi3-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl (22.1 MB view details)

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

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

jpeglib-1.0.2-cp38-abi3-macosx_10_9_x86_64.whl (10.7 MB view details)

Uploaded CPython 3.8+macOS 10.9+ x86-64

jpeglib-1.0.2-cp38-abi3-macosx_10_9_universal2.whl (14.5 MB view details)

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

File details

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

File metadata

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

File hashes

Hashes for jpeglib-1.0.2.tar.gz
Algorithm Hash digest
SHA256 25eadd5497c94771c53deb6aa6646f0030ac24509fa9c3b89e984e11390bf3d9
MD5 de03938b05944593d59901e6cfd7b5b6
BLAKE2b-256 99d75cadeb5790320923e205e5d682acdc63740bf40973d6bf15f7625a149eb8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for jpeglib-1.0.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 abcc0be1c0b6adbff02b3b42805474fddbf6ac3182d619117a7e7c5cfa8f9bd2
MD5 ab0daac3410b5091ec5fe733c31c5bf5
BLAKE2b-256 bb5b542403cdd0330733eeef421e4adc833d9862ed9b071f1607defe1f5cbe87

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for jpeglib-1.0.2-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 0b2d25da03f8710181367a4f1143215ad872c63b61dcad6665258b7ed051a5fb
MD5 d39e88d837ba12c8c160697e19892e19
BLAKE2b-256 a8c57d9d2e594b897b6c24fae5dcdd345bbcd3098f65e26943a12cb48a5d687d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jpeglib-1.0.2-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 feef6e94c34cf8b27f7a888c1c8567c34686c32b1e6edb16716931e4ee18fece
MD5 95da920cecb71e4e5d0d2872f586562f
BLAKE2b-256 5af4d7b8c2d3934208963fd2388cf4316043cb6c8e8c7d55780b8d9a45b4f8b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jpeglib-1.0.2-cp38-abi3-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl
Algorithm Hash digest
SHA256 e03cc447815efaf4cf0c22333ec207a9a8a0b9245bd0bafd15b30c2156ed1290
MD5 3d6ce21e37cc46be0598f4b7e6f65892
BLAKE2b-256 b4b5d3f0560b0b420aa5dccac348598217be8691e6cdd5a5269c805b85fe2e36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jpeglib-1.0.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e97ed4c232d0a76b80d823ac8a72ce0e8c68003929de599c27423dfdacf5e96
MD5 641acc7a5c5a7d72953075b82ae6d9e9
BLAKE2b-256 d89e3e72638f1baf356edc683aad86c08034b5facdec912253be846dc0a60ccd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jpeglib-1.0.2-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7d160a4b0169e737fef2b3a8e58074ccb463425baf47725ff480818fd26dd4ff
MD5 ffc7eb70b426687d93dd23d5fd2f9e96
BLAKE2b-256 3354d55db299c1572199847ef0707e1855e5a9f1d33abebc3148405c0760446d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jpeglib-1.0.2-cp38-abi3-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 fa065e7239664facd4a4c8910968ca729c75ad811aa36b23e3b8dba14d3163b2
MD5 a8cfb02e54cda76bb21baf2f0748f2a1
BLAKE2b-256 8fbd1e49f362ad057d237f27a5c4ef7bc35adc6e1928dab51dce3c565ad44d79

See more details on using hashes here.

Supported by

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