Generate beautiful link previews from any URL with smart image detection
Project description
LinkPreview CLI
🔗 Generate beautiful link previews from any URL with smart image detection
LinkPreview CLI is a powerful command-line tool that automatically extracts Open Graph metadata from websites and generates professional link preview images. It features intelligent image detection, JavaScript-rendered page support via Playwright, and both PNG and PDF export options.
✨ Features
- 🚀 Smart Extraction: Automatically detects and extracts Open Graph metadata
- 🧠 JavaScript Support: Handles modern SPAs and JavaScript-rendered pages with Playwright
- 🎨 Intelligent Layouts:
- Standalone mode for high-quality featured images
- Text overlay mode for square/tall images
- Traditional text+image layout for standard previews
- 📄 Multiple Formats: Export as PNG or PDF
- ⚡ Fast & Reliable: Built-in fallbacks and error handling
- 🔧 Manual Mode: Override automatic detection when needed
📦 Installation
Via Homebrew (Recommended)
brew install linkpreview-cli
Via pip
pip install linkpreview-cli
From Source
git clone https://github.com/yoel-frischoff/linkpreview-cli.git
cd linkpreview-cli
pip install -e .
🚀 Quick Start
# Generate a link preview
linkpreview https://example.com
# Export as PDF
linkpreview --pdf https://example.com
# Manual mode for blocked sites
linkpreview --manual https://example.com
# Custom output filename
linkpreview https://example.com my_preview.png
📋 Usage
linkpreview [OPTIONS] URL [OUTPUT_FILE]
Arguments:
URL The URL to generate a preview for
OUTPUT_FILE Output filename (optional, auto-generated from title)
Options:
--pdf Export as PDF instead of PNG
--manual, -m Force manual input of metadata
--help Show help message
🎯 Examples
Basic Usage
# Generate PNG preview
linkpreview https://newsroom.servicenow.com/press-releases/...
# Generate PDF preview
linkpreview --pdf https://canonical.com/blog/...
Advanced Usage
# Manual mode for sites that block automation
linkpreview --manual https://blocked-site.com
# Then enter title, description, image URL, and site name when prompted
# Custom filename with PDF export
linkpreview --pdf https://example.com conference_preview.pdf
🧠 Smart Image Detection
The tool automatically determines the best layout based on content quality:
- 📸 Standalone Mode: High-quality featured images (blog headers, announcements)
- 📝 Text Overlay: Square/tall images with title text on the left
- 📰 Traditional: Standard text + image layout
Detection criteria:
- URL patterns (
blog,featured,announcement, etc.) - Image dimensions and aspect ratios
- File naming conventions
- Open Graph metadata quality
🔧 Dependencies
- Python 3.8+
- Playwright (for JavaScript-rendered pages)
- Pillow (for image processing)
- Requests (for HTTP requests)
- BeautifulSoup4 (for HTML parsing)
📐 Output Specifications
- Dimensions: 722×144 pixels (optimized for social sharing)
- Formats: PNG (default) or PDF
- Fonts: System fonts with Unicode support
- Quality: High-resolution with crisp text rendering
🚫 Troubleshooting
Site Blocking Issues
If a website returns 403 Forbidden:
# Use manual mode
linkpreview --manual https://blocked-site.com
JavaScript-Rendered Pages
The tool automatically detects and handles these with Playwright, but if issues persist:
- Check your internet connection
- Try manual mode
- Verify the URL is correct
Font Issues
If text appears as squares:
- Ensure system fonts are properly installed
- Try different URLs to verify the issue is font-related
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add 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.
🙋 Support
🏗️ Built With
- Playwright - Browser automation for JavaScript pages
- Pillow - Python Imaging Library
- BeautifulSoup - HTML/XML parsing
- Requests - HTTP library for Python
Made with ❤️ by Yoel Frischoff
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 linkpreview_cli-1.0.0.tar.gz.
File metadata
- Download URL: linkpreview_cli-1.0.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
507c86e3359219274e4b7e17b4be1712e9e319557bc0a382b26850bc9b9f4941
|
|
| MD5 |
76260a78bdce8f575f9470cf6cd94d98
|
|
| BLAKE2b-256 |
00cce7b1c7530089c60d6785a315dbf7283ae7845880828d94e162f8b5d69d42
|
File details
Details for the file linkpreview_cli-1.0.0-py3-none-any.whl.
File metadata
- Download URL: linkpreview_cli-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d635de5e344a0f557603d126d2ac7c916688d619de28ed5cbc424c89dd111f11
|
|
| MD5 |
5779598eb38ffdc5838c74c3d6bf904a
|
|
| BLAKE2b-256 |
0c36b683e526108f853325757cdf557cc8b116c78ed8c3e4426693eeeb7ed24e
|