Skip to main content

Various ad hoc image related utility functions and classes.

Project description

Various ad hoc image related utility functions and classes.

Latest release 20260531: Tweak temp file name.

Short summary:

  • sixel: Return the filesystem path of a cached SIXEL version of the image at imagepath.
  • sixel_from_image_bytes: Return the filesystem path of a cached SIXEL version of the image data in image_bs.
  • ThumbnailCache: A class to manage a collection of thumbnail images.

Module contents:

  • sixel(imagepath: str) -> str: Return the filesystem path of a cached SIXEL version of the image at imagepath.
  • sixel_from_image_bytes(image_bs: bytes) -> str: Return the filesystem path of a cached SIXEL version of the image data in image_bs.
  • class ThumbnailCache(cs.cache.ConvCache): A class to manage a collection of thumbnail images.

ThumbnailCache.create_thumbnail(self, imagepath: str, thumbpath: str, max_edge: int): Write a thumbnail image no larger than max_edgexmax_edge of imagepath to thumbpath.

ThumbnailCache.thumb_for_path(self, dx, dy, imagepath): Return the path to the thumbnail of at least (dx,dy) size for imagepath. Creates the thumbnail if necessary.

Parameters:

  • dx, dy: the target display size for the thumbnail.
  • image: the source image, an image file pathname or a PIL Image instance.

The generated thumbnail will have at least these dimensions unless either exceeds the size of the source image. In that case the original source image will be returned; this result can be recognised with an identity check.

Thumbnail paths are named after the SHA1 digest of their file content.

ThumbnailCache.thumb_scale(self, dx, dy): Compute thumbnail size from target dimensions.

Release Log

Release 20260531: Tweak temp file name.

Release 20240422.1: Updated DISTINFO.

Release 20240422: Initial PyPI release with ThumbnailCache and SIXEL functions.

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

cs_imageutils-20260531.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

cs_imageutils-20260531-py2.py3-none-any.whl (3.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file cs_imageutils-20260531.tar.gz.

File metadata

  • Download URL: cs_imageutils-20260531.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for cs_imageutils-20260531.tar.gz
Algorithm Hash digest
SHA256 aaee2a6c3a0fc567090e36ae0c73bd7c9404d6e18dc5a440721409dcf96df985
MD5 bec1e369d76039f1c414c1d5aa7687c0
BLAKE2b-256 225ddfba3f323c764ddb274437abb7e4fccbd34891ec5d7c05f8f93330a882ca

See more details on using hashes here.

File details

Details for the file cs_imageutils-20260531-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cs_imageutils-20260531-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6b64160db734959c3fbf2c55e22566f99e5089215200c8d6c42afe16c2e26d4c
MD5 d42dd862325672e8d2f275254b1ee9bf
BLAKE2b-256 bc0127993c3baea4401ff847befff09ed090a505259f0b574198cc972d39fefd

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