Metadata-Version: 2.5
Name: is-page-empty
Version: 1.0.4
Summary: A very simple script that tests whether an image is likely empty.
Project-URL: Homepage, https://github.com/johannes-bauer/is_page_empty
Author-email: Johannes Bauer <atomm-clap@interesting-problems.de>
License: MIT
License-File: LICENSE
Keywords: argument-parser,cli,subcommands
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Provides-Extra: imageio
Requires-Dist: imageio>=2.0.0; extra == 'imageio'
Provides-Extra: pil
Requires-Dist: numpy>=2.2; extra == 'pil'
Requires-Dist: pillow>=12.0.0; extra == 'pil'
Provides-Extra: skimage
Requires-Dist: scikit-image>=0.20.0; extra == 'skimage'
Description-Content-Type: text/markdown

# is_page_empty

A simple package/script that checks whether a given image file is empty.

Install it with one of the optional dependencies `skimage`, `imageio`, or `pil` or provide that skimage, imageio, or pillow are installed.

Then you can check whether an image file is empty using the commandline:

```bash
if is_page_empty some_image.png; then echo "Yes, it's empty"; else echo "No, it's not empty."; fi
```

Or you can use the package to check programmatically

```python
import is_page_empty
if is_empty('path/to/image/file.png'):
    print("That file is empty.")
```

The script simply cuts the page into small squares, counts the number of pixels below a certain threshold in each, and compares the sum of those numbers in the squares with the highest numbers to a cutoff threshold.

This has been very robust, in my experience, for scanned text; in particular in double-sided prints, where some of the print on the other side may shine through, and in pages with punched holes, which are rendered black in the print.
