Skip to main content

JPEG-LS for Python via CharLS C++ Library

Project description

pyjpegls

Note
This is a fork of the original CharPyLS repository created to be able to add fixes and adaptions, as that repo is not maintained anymore. The rest of this file is unchanged from the original readme.

JPEG-LS for Python via CharLS C++ Library

I wrote this interface to enable easy access to the awesome JPEG-LS lossless image compression algorithm from within my Python application. I had no need to read/write anyone else's JPEG-LS image files, but rather I needed to compress some data structures internal to my application. This data was similar in nature to greyscale imagery such that it was an easy choice to leverage the existing CharLS C++ library I found on codeplex.com. I did eventually incorporate some basic file I/O functionality for my unit tests, and that's why I list Pillow below as a dependency.

I have tested this code on Windows 7 x64, Windows 8 x64, and Ubuntu x64. Note, even though this package has the odd name "CharPyLS", you will import it into your module as "jpeg_ls". Here is a quick example of using this tool to compress an image to a buffer in memory. For more details, check out the examples included within the source code.

    # Read in an image from an existing PNG file.
    fname_img = 'test/image.png'
    data_image = data_io.read_PIL(fname_img)

    # Compress image data to a sequence of bytes.
    data_buffer = jpeg_ls.encode(data_image)

    # Sizes.
    size_png = os.path.getsize(fname_img)
    print('Size of RGB 8-bit image data:  {:n}'.format(len(data_image.tostring())))
    print('Size of PNG encoded data file: {:n}'.format(size_png))
    print('Size of JPEG-LS encoded data:  {:n}'.format(len(data_buffer)))

    # Decompress.
    data_image_b = jpeg_ls.decode(data_buffer)

    # Compare.
    is_same = (data_image == data_image_b).all()
    print('Restored data is identical to original: {:s}'.format(str(is_same)))

The output generated by the above example should look like the following:

Size of RGB 8-bit image data:  5038848
Size of PNG encoded data file: 2409950
Size of JPEG-LS encoded data:  2088357
Restored data is identical to original: True

About JPEG-LS

  • From Wikipedia article: JPEG-LS (ISO-14495-1/ITU-T.87) is an accepted lossless image compression standard derived from the Hewlett Packard LOCO algorithm.
  • From CharLS codeplex site: CharLS is an optimized implementation of the JPEG-LS standard for lossless and near-lossless image compression. JPEG-LS is a low-complexity standard that matches JPEG 2000 compression ratios. In terms of speed, CharLS outperforms open source and commercial JPEG LS implementations.

Dependencies

  • Numpy
  • Cython (only for building and installing, not for everyday use)
  • Pillow (friendly fork of PIL, used here for file I/O with the example and during unit tests)
  • CharLS (source included as subfolder)

Project details


Download files

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

Source Distribution

pyjpegls-1.3.0.tar.gz (1.2 MB view hashes)

Uploaded Source

Built Distributions

pyjpegls-1.3.0-cp312-cp312-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

pyjpegls-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyjpegls-1.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

pyjpegls-1.3.0-cp312-cp312-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pyjpegls-1.3.0-cp312-cp312-macosx_10_9_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

pyjpegls-1.3.0-cp311-cp311-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

pyjpegls-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyjpegls-1.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

pyjpegls-1.3.0-cp311-cp311-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pyjpegls-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pyjpegls-1.3.0-cp310-cp310-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

pyjpegls-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pyjpegls-1.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

pyjpegls-1.3.0-cp310-cp310-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyjpegls-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pyjpegls-1.3.0-cp39-cp39-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

pyjpegls-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pyjpegls-1.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pyjpegls-1.3.0-cp39-cp39-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pyjpegls-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pyjpegls-1.3.0-cp38-cp38-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

pyjpegls-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pyjpegls-1.3.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pyjpegls-1.3.0-cp38-cp38-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pyjpegls-1.3.0-cp38-cp38-macosx_10_9_x86_64.whl (1.3 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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