checkcorruptedimages
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 crashedortimeout), 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 overMAX_IMAGE_PIXELS) count as corruption; API-deprecation warnings are never escalated. Withregard_warnings=False, only files Pillow cannot decode at all are reported. - Each image check is limited to
timeoutseconds (default: 60). Usetimeout=Noneto disable the limit. max_worker_memory(bytes;--max-memory-mbon 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 eachImageCheckResultas it completes; useful for progress reporting.- Options can be passed to the constructor or set as attributes:
verbose,regard_warningsandtimeout. - 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b87c377afa08417efbc7b0cf946c542a6815069404e74bb1b4982992d577ce7
|
|
| MD5 |
c78df3d01ecab18ed150409616417f81
|
|
| BLAKE2b-256 |
0f5f5270eb9357c5820514c75ae738026006f68e713785a2e74339d560657e0f
|
Provenance
The following attestation bundles were made for checkcorruptedimages-1.0.0.tar.gz:
Publisher:
publish.yml on carlosplanchon/checkcorruptedimages
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
checkcorruptedimages-1.0.0.tar.gz -
Subject digest:
2b87c377afa08417efbc7b0cf946c542a6815069404e74bb1b4982992d577ce7 - Sigstore transparency entry: 2621493715
- Sigstore integration time:
-
Permalink:
carlosplanchon/checkcorruptedimages@3c9fd68995635e1cf7b51ea0cfb189bed775cd45 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/carlosplanchon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c9fd68995635e1cf7b51ea0cfb189bed775cd45 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68497b2c6493a06754fdb5e4957dce116841328d05b676bf45b578b95c3e6698
|
|
| MD5 |
68bbd56bf387346989bb1a07c069f4e1
|
|
| BLAKE2b-256 |
ddb762dfeedb8d86568914ee3a8f1fde6fe5cf42f00d76d0ef5a791aa749ce4b
|
Provenance
The following attestation bundles were made for checkcorruptedimages-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on carlosplanchon/checkcorruptedimages
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
checkcorruptedimages-1.0.0-py3-none-any.whl -
Subject digest:
68497b2c6493a06754fdb5e4957dce116841328d05b676bf45b578b95c3e6698 - Sigstore transparency entry: 2621493703
- Sigstore integration time:
-
Permalink:
carlosplanchon/checkcorruptedimages@3c9fd68995635e1cf7b51ea0cfb189bed775cd45 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/carlosplanchon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c9fd68995635e1cf7b51ea0cfb189bed775cd45 -
Trigger Event:
push
-
Statement type: