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!
- 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
pip install ScreenshotScannerfrom screenshot_scanner import ScreenshotScanner
# Initialize scanner
scanner = ScreenshotScanner()
# Process an image (simple one-liner)
result = scanner.process("path/to/image.jpg")
print(result){
'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.
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.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
- There is no good tool without ML to detect screenshots. So i decided to come up with this.
- Author: AzwadFawadHasan
- GitHub: @AzwadFawadHasan
- Issues: GitHub Issues
If you find this project useful, please consider giving it a star on GitHub!
Made with ❤️ for better document verification by AzwadFawadHasan
