A heuristic-based tool to detect whether an image is a screenshot
Project description
ScreenshotScanner
A heuristic-based tool to detect whether an image is a screenshot or a photo of a physical document.
Star this repo if it helped you!
Features
- 13 Heuristic Checks - Multiple detection methods for high accuracy
- Simple API - Easy to integrate into existing workflows
- Detailed Metrics - Optional verbose mode for debugging
- No Training Required - Rule-based system, no ML models needed
- Fast Processing - Analyze images in milliseconds
Installation
Basic Installation
pip install ScreenshotScanner
Quick Start
from screenshot_scanner import ScreenshotScanner
# Initialize scanner
scanner = ScreenshotScanner()
# Process an image (simple one-liner)
result = scanner.process("path/to/image.jpg")
print(result)
Example Output
{
'is_screenshot': True,
'score': 8,
'confidence': 80.0,
'reasons': ['Has alpha channel', 'Common aspect ratio: 1.78', 'Low ELA: 45.32', 'No EXIF data', 'High sharpness: 156.23']
}
That's it! Just 3 lines of code to detect screenshots.
How It Works
ScreenshotScanner uses 13 different heuristic checks to determine if an image is a screenshot:
- Alpha Channel - Screenshots often have transparency
- Aspect Ratio - Common screen ratios (16:9, 4:3, etc.)
- Border Variance - Uniform borders indicate screenshots
- ELA (Error Level Analysis) - Lower compression artifacts in screenshots
- EXIF Data - Screenshots typically lack camera metadata
- Horizontal Edges - UI elements create horizontal patterns
- Moiré Patterns - Photos of screens show moiré, screenshots don't
- Noise Analysis - Screenshots have less sensor noise
- Sharpness - Screenshots are typically sharper
- Solid Color Ratio - UI elements have more solid colors
- Status Bar Detection - Mobile screenshots often have status bars
- Text Confidence - OCR works better on screenshot text
- Vertical Symmetry - UI layouts are often symmetric
Each check contributes to a final score. A score ≥ 5 (default threshold) indicates a screenshot.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Motivation
- There is no good tool without ML to detect screenshots. So i decided to come up with this.
Contact
- Author: AzwadFawadHasan
- GitHub: @AzwadFawadHasan
- Issues: GitHub Issues
Star
If you find this project useful, please consider giving it a star on GitHub!
Made with ❤️ for better document verification by AzwadFawadHasan
Project details
Release history Release notifications | RSS feed
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 screenshotscanner-0.1.0.tar.gz.
File metadata
- Download URL: screenshotscanner-0.1.0.tar.gz
- Upload date:
- Size: 11.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5678e324bc9f943ccd98a1554f3fce57679b5c3684b5fd482a58452346f9401f
|
|
| MD5 |
68c967fe141d5573e9b232e7a22c65fa
|
|
| BLAKE2b-256 |
58a1d2466945bdfc870634b8cf3142d4423c3cb8beeac5f72d20a6427888de56
|
File details
Details for the file screenshotscanner-0.1.0-py3-none-any.whl.
File metadata
- Download URL: screenshotscanner-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd76262e2c0ccbc0cd8adc90965301b5c5f458cd5bd8143ae91e9c28ad53ddd0
|
|
| MD5 |
1387aa001a7453e72a8855457c88e9b5
|
|
| BLAKE2b-256 |
9e1c3f06047c4a2e4c2a6ba0f9d6a537d611ff6312101884c92095a6d53bb158
|