Skip to main content

checkcorruptedimages

checkcorruptedimages banner

CI PyPI version Python versions License: MIT DeepWiki

Python module to check for corrupted images by fully decoding them with Pillow in crash-isolated worker processes.

Installation

Install with uv

uv add checkcorruptedimages

Install as a CLI tool

uv tool install checkcorruptedimages

Install with pip

pip install -U checkcorruptedimages

No system dependencies: Pillow is installed automatically.

HEIC/HEIF support

pip install -U "checkcorruptedimages[heif]"

Installs pillow-heif; the decoder workers register it automatically, so .heic/.heif files can be checked (e.g. --ext heic on the CLI).

Command line

checkcorruptedimages ~/Pictures
checkcorruptedimages ~/Pictures --ext jpg --ext png --lenient --timeout 120 -v

Prints one corrupted path per line (a summary goes to stderr) and exits with code 1 if any corrupted image was found. See checkcorruptedimages --help for all options. With uv you can try it without installing:

uvx checkcorruptedimages ~/Pictures

Usage

In [1]: import checkcorruptedimages

In [2]: from pathlib import Path

In [3]: m = checkcorruptedimages.CheckCorruptedImages(verbose=True)

In [4]: m.get_corrupted_images(
    folder_to_check=Path("/home/user/Pictures"),
    file_extensions_list=["jpg"]
    )

Path: /home/user/Pictures/notcorruptedimage.jpg, corrupted: False
Path: /home/user/Pictures/corruptedimage.jpg, corrupted: True, reason: OSError: image file is truncated (14 bytes not processed)
Out[4]: [PosixPath('/home/user/Pictures/corruptedimage.jpg')]

To also get the reason for each file, use get_check_results, which returns ImageCheckResult(file_path, corrupted, reason) records:

In [5]: m.get_check_results(
    folder_to_check=Path("/home/user/Pictures"),
    file_extensions_list=["jpg"]
    )

For many separate calls, keep the decoder workers alive with a session:

In [6]: with m.session() as s:
   ...:     s.is_image_corrupted(Path("/home/user/Pictures/a.jpg"))
   ...:     s.check_files([Path("/home/user/Pictures/b.jpg")])

Behavior

  • Every image is fully decoded with Pillow inside a pool of persistent worker subprocesses. A decoder crash or hang only kills a worker: the image is reported as corrupted (reason decoder crashed or timeout), the worker is respawned and the batch continues.
  • The folder is scanned recursively and file extensions are matched case-insensitively.
  • With regard_warnings=True (default), truncated files that would still partially decode and Pillow warnings (e.g. decompression bombs over MAX_IMAGE_PIXELS) count as corruption; API-deprecation warnings are never escalated. With regard_warnings=False, only files Pillow cannot decode at all are reported.
  • Each image check is limited to timeout seconds (default: 60). Use timeout=None to disable the limit.
  • max_worker_memory (bytes; --max-memory-mb on the CLI) applies a best-effort memory cap to each decoder worker on POSIX; a decode over the cap is reported as corrupted.
  • on_result= receives each ImageCheckResult as it completes; useful for progress reporting.
  • Options can be passed to the constructor or set as attributes: verbose, regard_warnings and timeout.
  • The package ships type hints (py.typed), checked with mypy in strict mode.

Download files

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

Source Distribution

checkcorruptedimages-1.0.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

checkcorruptedimages-1.0.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file checkcorruptedimages-1.0.0.tar.gz.

File metadata

  • Download URL: checkcorruptedimages-1.0.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for checkcorruptedimages-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2b87c377afa08417efbc7b0cf946c542a6815069404e74bb1b4982992d577ce7
MD5 c78df3d01ecab18ed150409616417f81
BLAKE2b-256 0f5f5270eb9357c5820514c75ae738026006f68e713785a2e74339d560657e0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for checkcorruptedimages-1.0.0.tar.gz:

Publisher: publish.yml on carlosplanchon/checkcorruptedimages

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

File details

Details for the file checkcorruptedimages-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: checkcorruptedimages-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for checkcorruptedimages-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68497b2c6493a06754fdb5e4957dce116841328d05b676bf45b578b95c3e6698
MD5 68bbd56bf387346989bb1a07c069f4e1
BLAKE2b-256 ddb762dfeedb8d86568914ee3a8f1fde6fe5cf42f00d76d0ef5a791aa749ce4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for checkcorruptedimages-1.0.0-py3-none-any.whl:

Publisher: publish.yml on carlosplanchon/checkcorruptedimages

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

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

0.2

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page