Skip to main content

Flexible and Customizable Image Display

Project description

Imshow

Flexible and Customizable Image Display




Imshow is a Python app to display images.

Imshow gives you:

  • Flexiblity - CLI & Python interface;
  • Customizability - visualize any data via the plugin system;
  • Fast & clean image display.

Installation

python3 -m pip install imshow

Usage

Command-Line

imshow examples/*.jpg
imshow examples --recursive  # --recursive (-r)
imshow examples -r --plugin tile --col 3  # --plugin (-p)

Python

import glob

import imgviz
import imshow

images = (imgviz.io.imread(filepath) for filepath in glob.glob("examples/*.jpg"))
imshow.imshow(images)

Builtin plugins

-p base (default)

imshow examples/*.jpg
imshow examples --recursive  # auto-search image files

-p tile

imshow examples/*.jpg -p tile --col 3 --row 3
imshow examples/*.jpg -p tile --col 3

-p mark

imshow examples/*[0-9].jpg -p mark --mark-file examples/mark.txt

How to create custom plugin

You can pass a Python file that contains class Plugin(base.Plugin) to --plugin, -p to customize the behaviour of Imshow. Below example shows a countdown from 10 to 0 displayed as images.

See plugins/base.py for the most basic example of scanning image files and displaying them. For more examples, check plugins folder.

imshow examples/*.jpg --plugin examples/countdown_plugin.py --number 10
import numpy as np
import imgviz
from imshow.plugins import base


class Plugin(base.Plugin):
    @staticmethod
    def add_arguments(parser):
        # define additional command line options
        parser.add_argument(
            "--number", type=int, default=10, help="number to count down from"
        )

    number: int

    def __init__(self, args):
        self.number = args.number

    def get_items(self):
        # convert command line options into items to visualize.
        # each item represent the chunk that is visualized on a single window.
        yield from range(self.number, -1, -1)

    def get_image(self, item):
        # convert item into numpy array
        image = np.full((240, 320, 3), 220, dtype=np.uint8)

        font_size = image.shape[0] // 2
        height, width = imgviz.draw.text_size(text=f"{item}", size=font_size)
        image = imgviz.draw.text(
            src=image,
            text=f"{item}",
            yx=(image.shape[0] // 2 - height // 2, image.shape[1] // 2 - width // 2),
            color=(0, 0, 0),
            size=font_size,
        )
        return image

License

MIT

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

imshow-0.2.3.post0.tar.gz (21.6 MB view details)

Uploaded Source

Built Distribution

imshow-0.2.3.post0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file imshow-0.2.3.post0.tar.gz.

File metadata

  • Download URL: imshow-0.2.3.post0.tar.gz
  • Upload date:
  • Size: 21.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for imshow-0.2.3.post0.tar.gz
Algorithm Hash digest
SHA256 869bc2c23de59495bbd17057ade1311b7a452a749af2ab50750c29cafb66a913
MD5 11ee9d24cf1abed9df1fb606e061cd7e
BLAKE2b-256 11ddc5e79491c8de739d533248dc334d2e454de6e36ab73d45d2713984dc69c0

See more details on using hashes here.

File details

Details for the file imshow-0.2.3.post0-py3-none-any.whl.

File metadata

  • Download URL: imshow-0.2.3.post0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for imshow-0.2.3.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 9349df65161fe642f9acaa5a894d5c8c8e7966e4663bbbe7bd0a8477a8800199
MD5 0f2e67759e045b19b282f5e40aa6e4ee
BLAKE2b-256 7f29bf41f353fc94a21374fab7e544b6f07dffe7053cd5ed040d5ce8da0c2f21

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page