pic
A powerful command-line tool to capture full-page screenshots and PDFs of websites using headless Chrome.
Features
- πΈ Capture full-page screenshots of any website
- π Export web pages as PDF documents
- π― Handle fixed headers/footers with adjustable margins
- π Automatic HTTPS protocol handling
- π Smart filename generation based on URL
- π Fast and lightweight
- π₯οΈ Cross-platform support
- πΌοΈ Automatically opens captured files after saving
Installation
Prerequisites
- Go 1.19 or higher
- Chrome or Chromium browser installed
Build from source
git clone https://github.com/kidandcat/pic.git
cd pic
go build -o pic main.go
Install with Go
go install github.com/kidandcat/pic@latest
Download Pre-built Binary
Visit the releases page to download pre-compiled binaries for your platform.
Usage
pic [options] <URL>
Options
--pdf - Output as PDF instead of PNG
--fixed-top <pixels> - Fixed top margin in pixels (for handling fixed headers)
--fixed-bottom <pixels> - Fixed bottom margin in pixels (for handling fixed footers)
Examples
# Basic screenshot
pic https://example.com
# Without protocol (defaults to HTTPS)
pic example.com
# Save as PDF
pic --pdf example.com
# Handle fixed header (100px) and footer (50px)
pic --fixed-top 100 --fixed-bottom 50 example.com
# Combine PDF output with fixed margins
pic --pdf --fixed-top 100 example.com
Example Captures
Click on any screenshot to view full size
Output
Screenshots are saved in the current directory with filenames based on the URL:
example.com β example.com.png
example.com/blog β example.com_blog.png
docs.github.com/en β docs.github.com_en.png
How it works
pic uses rod, a high-level Chrome DevTools Protocol library, to:
- Launch a headless Chrome instance
- Navigate to the specified URL
- Wait for the page to fully load and stabilize
- Capture a full-page screenshot or generate a PDF
- Handle fixed headers/footers if specified
- Save with a sanitized filename
- Automatically open the saved file
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- rod - The Chrome DevTools Protocol library that powers pic
- gson - Simple JSON library for Go