Skip to main content

A heuristic-based tool to detect whether an image is a screenshot

Project description

ScreenshotScanner Logo

ScreenshotScanner

License: MIT Python 3.8+ PyPI version Downloads CodeQL Status

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:

  1. Alpha Channel - Screenshots often have transparency
  2. Aspect Ratio - Common screen ratios (16:9, 4:3, etc.)
  3. Border Variance - Uniform borders indicate screenshots
  4. ELA (Error Level Analysis) - Lower compression artifacts in screenshots
  5. EXIF Data - Screenshots typically lack camera metadata
  6. Horizontal Edges - UI elements create horizontal patterns
  7. Moiré Patterns - Photos of screens show moiré, screenshots don't
  8. Noise Analysis - Screenshots have less sensor noise
  9. Sharpness - Screenshots are typically sharper
  10. Solid Color Ratio - UI elements have more solid colors
  11. Status Bar Detection - Mobile screenshots often have status bars
  12. Text Confidence - OCR works better on screenshot text
  13. 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

Star

If you find this project useful, please consider giving it a star on GitHub!


Made with ❤️ for better document verification by AzwadFawadHasan

Visitor Count

Project details


Download files

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

Source Distribution

screenshotscanner-0.1.1.tar.gz (11.9 MB view details)

Uploaded Source

Built Distribution

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

screenshotscanner-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file screenshotscanner-0.1.1.tar.gz.

File metadata

  • Download URL: screenshotscanner-0.1.1.tar.gz
  • Upload date:
  • Size: 11.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for screenshotscanner-0.1.1.tar.gz
Algorithm Hash digest
SHA256 62ac35a46addbc151f853e812faeea70313eaeb2be468615a6c6bbb3fa02270d
MD5 64f0916669027db686da922112e392db
BLAKE2b-256 985e25023ac3291cb2dcb5d74ff9ef5de353060b56dc3106289ca5f9c5c38f8b

See more details on using hashes here.

File details

Details for the file screenshotscanner-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for screenshotscanner-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a2eb840d2bc57c19f34b9e842ce8cc0e58238459d5caa57e1f744771b0f7d0e
MD5 149639dd838059faa057b0d441f538fb
BLAKE2b-256 09846a31a231e1a039bd5b64398f9707c3a2284ca0cabb4373d140eba7eccac9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page