Skip to main content

A TUI image viewer for Kitty terminal with keyboard navigation and PDF support

Project description

PMV โ€” Kitty TUI Image Viewer

A TUI (Text User Interface) image viewer optimized for the Kitty terminal using the Kitty Graphics Protocol. View images and PDFs directly in your terminal with keyboard navigation and lazy loading.

Features

  • ๐Ÿ–ผ๏ธ Image Viewing: Display images directly in Kitty terminal using the Kitty graphics protocol
  • ๐Ÿ“„ PDF Support: Convert and view PDF pages as images
  • โŒจ๏ธ Keyboard Navigation: Navigate through multiple images with intuitive keyboard controls
  • ๐Ÿš€ Lazy Loading: Efficient memory usage with on-demand image loading
  • ๐Ÿ“ Folder Support: View all images in a folder or recursively scan directories
  • ๐Ÿ’พ Image Caching: Smart LRU caching system for improved performance
  • ๐ŸŽจ Multiple Formats: Support for JPEG, PNG, GIF, BMP, WEBP, TIFF, SVG, and more

Requirements

  • Kitty Terminal: This application requires the Kitty terminal emulator
  • Python: 3.12 or higher
  • Dependencies:
    • pillow - Image processing (required)
    • pdf2image - PDF support (optional)
    • poppler-utils - System package for PDF rendering (optional)

Installation

Install with uv (Recommended)

Prerequisite: Have uv installed. See https://docs.astral.sh/uv/

Editable install (developer mode):

uv pip install -e .

# Run the CLI (after install places the script on PATH for the venv)
pmv images/

Run without installing:

uv run main.py images/

Global tool-style install (no venv activation):

# Installs an isolated tool environment and exposes `pmv` on PATH
uv tool install --reinstall .

# Use anywhere
pmv images/

# Upgrade later from the same source
uv tool install --reinstall .

# Uninstall
uv tool uninstall pmv

Install with pip

# Clone or navigate to the project directory
cd /path/to/pymv

# Install the package
pip install -e .

# Or install dependencies manually
pip install pillow pdf2image

PDF Support (Optional)

For PDF viewing, install additional dependencies:

# Install Python package
pip install pdf2image

# Install system package for PDF rendering
# On Debian/Ubuntu:
sudo apt install poppler-utils

# On macOS:
brew install poppler

# On Fedora/RHEL:
sudo dnf install poppler-utils

Usage

Basic Commands

# View a single image
pmv image.jpg

# View multiple images
pmv image1.jpg image2.png image3.gif

# View all images in a folder
pmv /path/to/images/

# View images using wildcards
pmv *.jpg

# Mix folders and files
pmv folder1/ folder2/ image.png

Advanced Options

# Recursively scan folders for images
pmv -r /path/to/images/
pmv --recursive ~/Pictures/

# View PDF file (each page as an image)
pmv --pdf document.pdf

# Skip Kitty terminal check (use at your own risk)
pmv --skip-check image.jpg

# Get help
pmv --help

Keyboard Controls

Once the viewer is running, use these controls to navigate:

Key Action
Arrow Left / Right Navigate between images
A / D Navigate between images (alternative)
H / L Navigate between images (Vim-style)
Q or ESC Quit the viewer

Usage Examples

Example 1: View all images in current directory

pmv *.png

Example 2: View all images recursively in a directory tree

pmv -r ~/Pictures/

Example 3: View a PDF document

pmv --pdf report.pdf

Example 4: View specific images from different locations

pmv ~/photo1.jpg ~/Documents/diagram.png ~/Downloads/screenshot.png

Example 5: View all images in multiple folders

pmv ~/Photos/ ~/Screenshots/ ~/Downloads/

Supported Image Formats

  • JPEG (.jpg, .jpeg)
  • PNG (.png)
  • GIF (.gif)
  • BMP (.bmp)
  • WEBP (.webp)
  • TIFF (.tiff, .tif)
  • ICO (.ico)
  • PPM, PGM, PBM, PNM (.ppm, .pgm, .pbm, .pnm)
  • SVG (.svg)

Project Structure

pymv/
โ”œโ”€โ”€ main.py              # Main entry point and CLI
โ”œโ”€โ”€ show_image.py        # Backward compatibility wrapper
โ”œโ”€โ”€ pyproject.toml       # Project configuration and metadata
โ”œโ”€โ”€ README.md            # This file
โ”œโ”€โ”€ image_viewer/        # Core modules
โ”‚   โ”œโ”€โ”€ __init__.py      # Module exports
โ”‚   โ”œโ”€โ”€ cache.py         # LRU image caching system
โ”‚   โ”œโ”€โ”€ kitty.py         # Kitty graphics protocol implementation
โ”‚   โ”œโ”€โ”€ pdf_processor.py # PDF to image conversion
โ”‚   โ”œโ”€โ”€ processor.py     # Image loading and processing
โ”‚   โ”œโ”€โ”€ show.py          # Display utilities
โ”‚   โ”œโ”€โ”€ terminal.py      # Terminal helper functions
โ”‚   โ””โ”€โ”€ viewer.py        # Main TUI viewer with navigation
โ”œโ”€โ”€ images/              # Sample images (if any)
โ””โ”€โ”€ pdfs/                # Sample PDFs (if any)

Architecture

The project is organized into modular components:

  • TerminalHelper: Terminal information and control utilities
  • ImageProcessor: Image loading, resizing, and format conversion
  • KittyGraphicsProtocol: Low-level Kitty graphics protocol implementation
  • ImageCache: LRU-based caching for preloaded images
  • ImageViewer: Main TUI application with keyboard navigation
  • PDFProcessor: PDF to image conversion utilities

Troubleshooting

"Kitty terminal not detected" error

Make sure you're running the application inside the Kitty terminal. If you're certain you're using Kitty but still get this error, you can bypass the check:

pmv --skip-check image.jpg

PDF viewing not working

Ensure you have the required dependencies installed:

pip install pdf2image

# Install poppler-utils
# On Debian/Ubuntu:
sudo apt install poppler-utils

# On macOS:
brew install poppler

Images not displaying correctly

  • Ensure your Kitty terminal is up to date
  • Check that your terminal window is large enough to display the image
  • Verify the image file is not corrupted
  • Try running with --skip-check if terminal detection fails

Performance issues with many images

The viewer uses lazy loading and caching to optimize performance. Images are only loaded when viewed, and recently viewed images are cached for quick access.

Building Distributables

Build wheel and source distributions:

uv build
ls dist/

Development

To contribute or modify the project:

  1. Clone the repository
  2. Install in editable mode: uv pip install -e .
  3. Make your changes
  4. Test with: pmv test_images/

License

This project is open source. See LICENSE file for details (if available).

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Credits

Built with:

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

pmv-0.2.0.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

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

pmv-0.2.0-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file pmv-0.2.0.tar.gz.

File metadata

  • Download URL: pmv-0.2.0.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pmv-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1db3b4603e3ad75c53d859fadad527aae328ac85a3e37cc5d93b5d45b333edd2
MD5 b2219648b8409d3b11f192b89233bd74
BLAKE2b-256 86ab7ad556d356899cd9a9be11bfe9a3b2aa27466437e53f2798d1d90d140002

See more details on using hashes here.

File details

Details for the file pmv-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pmv-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pmv-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50b515c42d8e30b54b391c5eac772e91e3ee60657f04bbd762bc69958b3d95ee
MD5 de1f2b68d2538f40445927588db4cfe8
BLAKE2b-256 245c77839e2d7c39035551e21f7236606fa986a0524f969b91ddadf2ce620f4a

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