A cross-platform, feature-rich desktop screenshot capture tool with support for multiple capture modes, formats, and intuitive CLI interface.
-
Multiple Capture Modes
- Full screen capture
- Region-based capture (specify exact coordinates)
- Active window capture (platform-dependent)
-
Wide Format Support
- PNG, JPEG, BMP, GIF, TIFF, WebP
- Configurable JPEG quality settings
-
Cross-Platform
- Windows, Linux, macOS support
- Platform-specific optimizations
-
Flexible Configuration
- Command-line arguments for one-time use
- Persistent configuration file for defaults
- Easy-to-use configuration commands
-
Developer-Friendly
- Clean, well-documented API
- Type hints throughout
- Comprehensive test coverage
- Easy to integrate into other projects
# Clone the repository
git clone https://github.com/codeforgood-org/desktop-screenshot-capturer.git
cd desktop-screenshot-capturer
# Install dependencies
pip install -r requirements.txt
# Install the package
pip install -e .pip install screenshot-capturer# Capture full screen (saves to current directory with timestamp)
screenshot-capturer
# Capture to specific file
screenshot-capturer -o ~/Pictures/my_screenshot.png
# Capture a specific region (x, y, width, height)
screenshot-capturer -m region -r 100,100,800,600
# Capture as JPEG with custom quality
screenshot-capturer -f jpeg -q 85 -o screenshot.jpg
# Show current configuration
screenshot-capturer --show-config
# Set default output format
screenshot-capturer --set-default-format png
# Set default output directory
screenshot-capturer --set-default-dir ~/Picturesfrom screenshot_capturer import ScreenshotCapturer, CaptureMode, Region
# Initialize the capturer
capturer = ScreenshotCapturer()
# Capture full screen
screenshot = capturer.capture_fullscreen()
capturer.save_screenshot(screenshot, "fullscreen.png")
# Capture a specific region
region = Region(x=100, y=100, width=800, height=600)
screenshot = capturer.capture_region(region)
capturer.save_screenshot(screenshot, "region.png")
# Quick capture with sensible defaults
capturer.quick_capture(
filepath="screenshot.png",
mode=CaptureMode.FULLSCREEN,
format="PNG",
quality=95
)
# Get screenshot as bytes (e.g., for uploading)
screenshot = capturer.capture_fullscreen()
image_bytes = capturer.get_screenshot_bytes(screenshot, format="PNG")usage: screenshot-capturer [-h] [--version] [-m {fullscreen,region,active_window}]
[-r X,Y,W,H] [-o PATH] [-f {png,jpeg,jpg,bmp,gif,tiff,webp}]
[-q N] [--show-config] [--set-default-format FORMAT]
[--set-default-dir PATH] [-v] [-q]
Cross-platform desktop screenshot capture tool
options:
-h, --help show this help message and exit
--version show program's version number and exit
-m, --mode Screenshot capture mode (default: fullscreen)
-r, --region X,Y,W,H Region to capture in format 'x,y,width,height'
-o, --output PATH Output file path
-f, --format Output image format (default: png)
-q, --quality N JPEG quality 1-100 (default: 95)
--show-config Display current configuration and exit
--set-default-format Set default output format in config
--set-default-dir Set default output directory in config
-v, --verbose Enable verbose output
-q, --quiet Suppress all output except errors
The tool stores configuration in ~/.config/screenshot-capturer/config.json.
Default configuration:
{
"default_format": "PNG",
"default_quality": 95,
"default_output_dir": "."
}You can modify these defaults using command-line arguments or by editing the config file directly.
- Python 3.8 or higher
- Pillow (PIL) library
# Clone the repository
git clone https://github.com/codeforgood-org/desktop-screenshot-capturer.git
cd desktop-screenshot-capturer
# Install development dependencies
pip install -r requirements-dev.txt
# Install pre-commit hooks
pre-commit install# Run all tests
pytest
# Run with coverage
pytest --cov=screenshot_capturer --cov-report=html
# Run specific test file
pytest tests/test_capturer.py# Format code with black
black src/ tests/
# Lint with flake8
flake8 src/ tests/
# Type check with mypy
mypy src/
# Run all checks
make checkmake install # Install the package
make test # Run tests
make coverage # Run tests with coverage
make lint # Run linters
make format # Format code
make check # Run all quality checks
make clean # Clean build artifacts
make docs # Build documentationsrc/screenshot_capturer/
├── __init__.py # Package initialization and exports
├── __main__.py # Entry point for module execution
├── capturer.py # Core screenshot capture functionality
├── cli.py # Command-line interface
├── config.py # Configuration management
└── exceptions.py # Custom exceptions
tests/ # Comprehensive test suite
docs/ # Additional documentation
examples/ # Usage examples
| Platform | Fullscreen | Region | Active Window |
|---|---|---|---|
| Windows | ✅ | ✅ | ✅ |
| Linux | ✅ | ✅ | |
| macOS | ✅ | ✅ | ✅ |
*Active window capture on Linux requires additional tools (xdotool, wmctrl). Use region capture as an alternative.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and code quality checks (
make check) - Commit your changes (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a list of changes and version history.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Built with Pillow (PIL)
- Inspired by various screenshot tools in the Python ecosystem
- GUI interface using tkinter or PyQt
- Screen recording functionality
- OCR text extraction from screenshots
- Cloud storage integration
- Screenshot annotation tools
- Hotkey support for quick captures
- Multi-monitor support improvements
- Image optimization and compression options
- Dang Linh Anh - Initial work - [email protected]
Made with ❤️ by the Code for Good community