Skip to main content

Convert SVG from clipboard to PNG and copy back to clipboard

Project description

svg2png-clipboard

Convert SVG content from clipboard to PNG and copy it back - perfect for quickly converting SVG icons for use in applications that don't support SVG.

Features

  • 📋 Read SVG directly from clipboard
  • 🖼️ Convert to PNG with customizable size
  • 📋 Copy PNG back to clipboard automatically
  • 💾 Optional file input/output
  • 🔔 macOS notifications
  • ✅ Robust error handling and dependency checking

Requirements

  • macOS (uses pbpaste and osascript)
  • Python 3.8+
  • rsvg-convert (from librsvg)

Installation

Using pipx (Recommended)

# Install system dependency first
brew install librsvg

# Install with pipx
pipx install svg2png-clipboard

Using pip

# Install system dependency
brew install librsvg

# Install package
pip install svg2png-clipboard

From source

# Clone repository
git clone https://github.com/yourusername/svg2png-clipboard
cd svg2png-clipboard

# Install system dependency
brew install librsvg

# Install package
pip install -e .

Usage

Basic usage (clipboard to clipboard)

# Copy SVG to clipboard, then:
svg2png-clipboard

Specify output size

svg2png-clipboard --size 512  # Creates 512x512 PNG

File operations

# Read from file, copy to clipboard
svg2png-clipboard --input icon.svg

# Read from clipboard, save to file
svg2png-clipboard --output icon.png

# Read from file, save to file
svg2png-clipboard --input icon.svg --output icon.png

Other options

# Disable notifications
svg2png-clipboard --no-notification

# Verbose output
svg2png-clipboard --verbose

# Show help
svg2png-clipboard --help

Examples

  1. Quick icon conversion: Copy an SVG icon from a website, run svg2png-clipboard, paste the PNG anywhere

  2. Batch conversion with custom size:

    svg2png-clipboard -i logo.svg -o logo-256.png -s 256
    
  3. Debug mode:

    svg2png-clipboard --verbose
    

Troubleshooting

"rsvg-convert is not installed"

Install librsvg using Homebrew:

brew install librsvg

"This tool only works on macOS"

This tool requires macOS-specific utilities (pbpaste, osascript). For other platforms, consider using the file input/output options with platform-specific clipboard tools.

Invalid SVG content

Make sure the clipboard contains valid SVG. You can verify with:

pbpaste | head -n 5

Development

# Install in development mode
pip install -e ".[dev]"

# Run tests (if available)
pytest

# Build package
python -m build

License

MIT License

Author

Hsieh-Ting Lin, the Lizard 🦎

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

svg2png_clipboard-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

svg2png_clipboard-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file svg2png_clipboard-0.1.0.tar.gz.

File metadata

  • Download URL: svg2png_clipboard-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for svg2png_clipboard-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e588c7c162751e2a9280731c1e0ba080f678be792da6ed5c30b17315460de7f
MD5 f1143932410df097e2234e465231e0b8
BLAKE2b-256 1a16a9030d7e2e4db9f2387a1e6f6a93bf201a4bfe234ae40f13cc23ce04ac70

See more details on using hashes here.

File details

Details for the file svg2png_clipboard-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for svg2png_clipboard-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7be53edcf1951d7272970d1ac9464488a7d3f88f00b78da2cf7c664c5e63934
MD5 b3449cc67f7025cf20f77196e484f4ef
BLAKE2b-256 3ac1738e757fd7fefa368fabd6f36c0f82a6cfd14bd3f57e6d4adbc4cb1e04c2

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