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.1.tar.gz (33.0 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.1-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pmv-0.2.1.tar.gz
  • Upload date:
  • Size: 33.0 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.1.tar.gz
Algorithm Hash digest
SHA256 48f90e6e524595607e7354478f3e060866a349fc98f63d8c266e0f52faee9a73
MD5 e8172631aa99a4f76b21add30826470b
BLAKE2b-256 f883937537e00c81d141f9b1c105be629f76e2c4fcf8d0509ed046317ffbaf2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pmv-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 33.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bac1e43dfeed57f8ad5980d2f31b4aa26e4329cfb60c065255daf4dd82f3ea50
MD5 19edc3e76ea8105a3abd7f65b0be833e
BLAKE2b-256 349bda1fe41fca6d33b4e0ac534201f5adb00ae344b2c2e80ec8716c767cfa1c

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