github crates.io ci docs-rs

miniview

'mini' as in, it can't do much =)

Display an image within a (graphical) window.

Install

With cargo install: cargo install --force miniview

Pre build binary: see releases

Usage (binary)

| Usage | Linux example | Windows example (cmd.exe) | |----------------------------------------|------------------------------------------------|------------------------------------------------| | miniview <PATH_TO_IMAGE> | miniview image.png | miniview image.png | | miniview --from-path <PATH_TO_IMAGE> | miniview --from-path image.png | miniview --from-path image.png | | miniview --from-stdin-path | echo image.png \| miniview --from-stdin-path | echo image.png \| miniview --from-stdin-path | | miniview --from-stdin-bytes | cat image.png \| miniview --from-stdin-bytes | type image.png \| miniview --from-stdin-bytes |


Flags & Options

| Flag/Option | Description | | --- | --- | | --fullscreen | Set the window to fullscreen | | --allow-window-resizing | Allow the window to resize (doesn't resize the image!) | | --close-after <n> | Close the window after n milliseconds |


Keyboard shortcuts

Press ESC to exit the image window.

Usage example (library)

```rust use miniview::config::ConfigBuilder; use std::time::Duration;

fn main() { let config = ConfigBuilder::frompath(concat!(env!("CARGOMANIFESTDIR"), "/resources/plant.jpg")) .setfullscreen(true) .setlazywindow(false) .build();

let controls = MiniView::show(config).expect("unable to create miniview");

// do some important other work!
std::thread::sleep(Duration::from_millis(1000));

let closed = controls.close();
assert!(closed.is_ok());

} ```

Backends

MiniView supports two backends: piston-window and pixels. You can switch between backends on compile time. This requires setting Cargo features. The piston-window backend can be enabled using the backend_piston_window feature, and the pixels backend can be enabled using the backend_pixels feature.

The default backend is pixels. This backend will be used if no-default-features is not specified. Note that the default backend is not available on MacOS.

The next sections provide examples, on how to enable each backend. Only one backend should be enabled at a time.

backend: piston-window

Platform support

Supported platforms: * any platform supported by piston-window with Glutin, including: * Linux * MacOS * Windows

Configuration examples

When building MiniView, the piston-window backend can be used by compiling with: bash cargo run --no-default-features --features backend_piston_window

When using MiniView as a library, you can use: toml [dependencies.miniview] version = "*" # select the latest version here default-features = false features = ["backend_piston_window"]

or

toml [dependencies] miniview = { version = "*", default-features = false, features = ["backend_piston_window"] }

backend: pixels

Platform support

Supported platforms: * Linux * Dragonfly * FreeBSD * NetBSD * OpenBSD * Windows

Note: MacOS is not yet supported for this backend.

Configuration examples

When building MiniView, the pixels backend can be used by compiling with: bash cargo run --no-default-features --features backend_pixels

When using MiniView as a library, you can use: toml [dependencies.miniview] version = "*" # select the latest version here default-features = false features = ["backend_pixels"]

or

toml [dependencies] miniview = { version = "*", default-features = false, features = ["backend_pixels"] }

Suggestions, Questions, Bugs

Feel free to open an issue :mailboxwithmail: if you have a suggestion, a question or found a bug =).

🎸 🎺 🎻 🎷