Skip to main content

Fast and memory-efficient, compressed in-memory image storage for C++ and Python.

Project description

compressed-image

compressed-image is a header-only library for reading, storing and modifying images and channels as losslessly compressed in-memory buffers allowing for very memory-efficient representations of these. This library acts as a stop-gap between storing images purely in-memory and reading them from disk on-demand.

It trades a bit of performance for significantly lower memory usage. For more detailed information please have a look at the benchmark section on readthedocs.

It is written entirely using C++20 while also providing pre-built python binaries that are pip-installable.

Features

  • Storing images as compressed buffers
  • Support for multiple compressions algorithms such as lz4, zstd, blosclz etc.
  • Reading files directly from disk into compressed chunks for low memory usage
  • Random access compression/decompression without having to decompress the entire image
  • Lazy image/channel representations with extremely low memory footprints
  • Cross-platform support (linux, windows, macos)
  • Interoperability with NumPy

When should you use this?

This library is for you if you want to optimize memory usage in your application and still work efficiently with image data. It's especially useful when:

  • You need to keep many images in memory at once but don't want to pay the full memory cost.
  • You're working with high-resolution images or large datasets and want to avoid I/O bottlenecks.
  • You want fast, random access to image chunks without having to decompress the entire image up front.
  • You're building tools, pipelines, or applications that process images frequently but can't afford the memory footprint of uncompressed data.

If you're hitting memory limits or just want a smarter way to handle images in-memory without sacrificing speed, compressed-image was built for that.

Performance

The compressed-image library is aimed at high performance computing allowing you to store many images in-memory simultaneously while not having to pay the associated memory cost. It performs equal or faster during image reads with significantly lower memory usage

A graph showing the relationship of decoding speed using OpenImageIO vs compressed::image showing roughly equal performance

A graph showing the relationship of memory usage during read using OpenImageIO vs compressed::image showing significantly lower usage with compressed::image

Quickstart

This is a simple example of getting you up and running with compressed-image, loading a file from disk and then interacting with the channels. For more detailed examples have a look at the examples/ directory

cpp

#include <compress/image.h>

auto image = compressed::image<uint8_t>::read("/some/file/path");
// Retrieve the red channel from the image
auto channel_r = image.channel("R"); // could also get it via image.channel(0)

// Iterate over the chunks in the channel, this will decompress the 
// chunk and recompress it on the fly.
for (auto chunk_r : channel_r)
{
   std::for_each(std::execution::par_unseq, chunk_r.begin(), chunk_r.end(), [](auto& pixel)
      {
         // perform some computation on the chunk in parallel
      });
}

// Otherwise you can also get the image data directly as a full channel. Although this is less memory efficient
std::vector<uint8_t> channel_r_decompressed = channel_r.get_decompressed();

python

import compressed_image as compressed

image = compressed.Image.read(np.float16, "/some/file/path", subimage=0)
channel_r: compressed.Channel = image[0]

# Iterate over the chunks in the channel, this is more memory efficient than decompressing all the data
# at once
for chunk_idx in range(channel_r.num_chunks()):
   chunk = channel_r.get_chunk(chunk_idx)

   # modify chunk as you wish

   # set the chunk back again, this will recompress the data
   channel_r.set_chunk(chunk, chunk_idx)

# If you instead wish to decompress the buffer as one you can do that too:
channel_r_decompressed = channel_r.get_decompressed()

Documentation

The complete user-facing documentation is hosted on readthedocs where you can find more information on benchmarks and technical class documentation.

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

compressed_image-1.0.1.tar.gz (15.3 MB view details)

Uploaded Source

Built Distributions

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

compressed_image-1.0.1-cp313-cp313-win_amd64.whl (5.8 MB view details)

Uploaded CPython 3.13Windows x86-64

compressed_image-1.0.1-cp313-cp313-manylinux_2_34_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

compressed_image-1.0.1-cp313-cp313-macosx_14_0_arm64.whl (7.8 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

compressed_image-1.0.1-cp312-cp312-win_amd64.whl (5.8 MB view details)

Uploaded CPython 3.12Windows x86-64

compressed_image-1.0.1-cp312-cp312-manylinux_2_34_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

compressed_image-1.0.1-cp312-cp312-macosx_14_0_arm64.whl (7.8 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

compressed_image-1.0.1-cp311-cp311-win_amd64.whl (5.8 MB view details)

Uploaded CPython 3.11Windows x86-64

compressed_image-1.0.1-cp311-cp311-manylinux_2_34_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

compressed_image-1.0.1-cp311-cp311-macosx_14_0_arm64.whl (7.8 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

compressed_image-1.0.1-cp310-cp310-win_amd64.whl (5.8 MB view details)

Uploaded CPython 3.10Windows x86-64

compressed_image-1.0.1-cp310-cp310-manylinux_2_34_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

compressed_image-1.0.1-cp310-cp310-macosx_14_0_arm64.whl (7.8 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

compressed_image-1.0.1-cp39-cp39-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.9Windows x86-64

compressed_image-1.0.1-cp39-cp39-manylinux_2_34_x86_64.whl (7.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

File details

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

File metadata

  • Download URL: compressed_image-1.0.1.tar.gz
  • Upload date:
  • Size: 15.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for compressed_image-1.0.1.tar.gz
Algorithm Hash digest
SHA256 96c7d701b529d4123b25fbdf688dc514adc9a3eb9cdfa34977c3d819deac03e0
MD5 13cb573514ceb98f595bd5b5375bd48b
BLAKE2b-256 aee704bb0647119e5678dd754aa21cb310eb2413355fd32fc6355ead77b32bfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1.tar.gz:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 bdb62e993c5bb57aee1979400985111e0866aff2633e75e8a29e768af0ae85c1
MD5 b1ff3c05edd8171237d68e8c80edc6bb
BLAKE2b-256 9667f7de99657624d5cc7cf1cf753a187754f339cfa6a567713c0245165afb41

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp313-cp313-win_amd64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a71dc9abaa5deabb2f9e046afb25f0f350ca0f26ef0aa7d0bdffc9657183d9fc
MD5 cdfac084d1821cbf4620b538bcdb8e6f
BLAKE2b-256 5515fe6b380f3d560a3d629a08a6f7d05695d21715c8837156436d2c313aa270

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0ce60a96c2d48eaf6a592cd6b9798763985b516443f8a487baa90ab088f036b5
MD5 c8603b417ec131b422ead7ce9de08337
BLAKE2b-256 843b0b5d0d3dbd26791d81fdf27d5094143e7dd609b3223b17710420b1be0943

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp313-cp313-macosx_14_0_arm64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c8a7c78266e064fbb43d0c3d245f5063b300bbde7747b794375125306e34a7c3
MD5 c56e0351c6b5f240abd9d8049df48007
BLAKE2b-256 ae5143e92d6a4775988db05e8a587c1383664a6b4546852e53f007ac58e5d623

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp312-cp312-win_amd64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f755b4f843ccebd700c695c4bb4261e9427628c48bb98c3409a3409668570752
MD5 de3cee88ae2d69c1c9d26c1818c7b2bd
BLAKE2b-256 a213a097306685aa0cf0760e6b5bee81f4a53fd059fabb093295c4619241af1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9d167d1581c63435139904a2c23e19e1e48387354ee1f13bd14a070b8554bc2c
MD5 2ff6f062d2d61519f7b68986aaef5403
BLAKE2b-256 06103cd23f536f97990875441dcb0eb8c72bb6f073e0e6019f43e4c2d5f8a14a

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp312-cp312-macosx_14_0_arm64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4bdd2d1525f6d479e5291911e46720c52f8e53ece841643a92cf8adc22e74555
MD5 8755a978b96e20334af4466d49872eef
BLAKE2b-256 ff5c5562376faa388c1472120adbda0396385423572bd7a8a3d5578bc520ba7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp311-cp311-win_amd64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2f1f9a5fd144b05e0bcfbb440d2b5d8ee0813f2c087522b1ec4745d8a1b1ce99
MD5 5a3989225692cddb145657bbc1745a4d
BLAKE2b-256 1c79bac0e262765ad76232e37b8857c29bbad540e4c086d0ccfb0b1d53ee4582

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 fa0c9f4cbf6e89ee57d94ad89ca41ea7201d7d4ace8c6701df482df11ed248bc
MD5 1a0c2716aa18edceed7f2dd4608386b0
BLAKE2b-256 bc2db0203c9299493025b1d110e3820e1fec8a01569ab65c7fbf0526c41553cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp311-cp311-macosx_14_0_arm64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 747dd23def3332202af87362c783500a742d849d1525d5844ad48c3bd6955e30
MD5 01cb55c23b09801c4dbb12703e903987
BLAKE2b-256 02bced4d481d678caa9f3ff4745c73d6ff9fbc70e03115172eb526d50202e7aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp310-cp310-win_amd64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 117e464a9bf69b8db0e90c84f3697097f11493e612e4185129925c2d0973f296
MD5 0263729e19f4f3e8ffb4d97821e9b84e
BLAKE2b-256 cb8593087edcdaf6d0515ac8f493f0c8e4ba1c1cb38ed9c3bb6f0b7a3b7149ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 af018e31cd1d5920ee447a4093f6a0e6017f7c0e1ac4c72de53243d3ca25d1e8
MD5 7a61a7146965ac8a865fc00eeb172091
BLAKE2b-256 a0dae80f1ea6108fe7f3ef30c4dae16549fe74b60ef8ab08fb404833dc152853

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp310-cp310-macosx_14_0_arm64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 764d35f8ba148a1e1b57ce82c8f2967df83915b4f83c10943b0b3b68643abec0
MD5 2d6b9788bdeec6811d210407938fe770
BLAKE2b-256 142affb8b0c64b510ffd6572880c15e0bfa61749e6ca8d45d5a30c4513fa8c09

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp39-cp39-win_amd64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compressed_image-1.0.1-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for compressed_image-1.0.1-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 548a0f1b40c6c8eba865bd688d8006ef81833e8358137b935186cdcec42aa83e
MD5 224a7f52cc9199c428d62205758055c6
BLAKE2b-256 25fce4edc85e1220aefa0bb07cf1cb90cd7261730b15001365a5e70f909d1619

See more details on using hashes here.

Provenance

The following attestation bundles were made for compressed_image-1.0.1-cp39-cp39-manylinux_2_34_x86_64.whl:

Publisher: cmake-wheels.yml on EmilDohne/compressed-image

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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