Giter VIP home page Giter VIP logo

miniview's Introduction

github crates.io ci docs-rs

miniview

MiniView is a bare-bones image viewer intended to be used during development and testing. MiniView can be called as binary from the CLI, and used as a Rust library.

To see what it can do, and whether it would fit your purpose, please see:

MiniView is not intended to be used as your primary image viewer. For that purpose, I would recommend Emulsion.

Install

Binary installation

With cargo install: cargo install miniview

Pre-build binary: see releases

Add library dependency

Run cargo add miniview with cargo-edit, or add miniview as a dependency to your Cargo.toml:

miniview = "*" # replace `*` with the latest version

Usage

Instructions for CLI use

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.

Instructions for library use

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

fn main() {
    let config =
        ConfigBuilder::from_path(concat!(env!("CARGO_MANIFEST_DIR"), "/resources/plant.jpg"))
            .set_fullscreen(true)
            .set_lazy_window(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

Platform Supported Tested Notes
Linux โœ… โœ…
MacOS MacOS does not allow the creation of graphical windows off the main thread.
Windows โœ… โœ…
... other piston-window + glutin platforms โœ… Assuming graphical windows can be created off the main thread.

Configuration examples

When building MiniView, the piston-window backend can be used by compiling with:

cargo run --no-default-features --features backend_piston_window 

When using MiniView as a library, you can use:

[dependencies.miniview]
version = "*" # replace `*` with the latest version
default-features = false 
features = ["backend_piston_window"]

or

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

NB: replace * in version = "*" with any supported version.

backend: pixels

Platform support

Platform Supported Tested Notes
Linux โœ… โœ…
Windows โœ… โœ…
MacOS MacOS does not allow the creation of graphical windows off the main thread.
FreeBSD โœ…
DragonflyBSD โœ…
NetBSD โœ…
OpenBSD โœ…
... other pixels + winit platforms Assuming graphical windows can be created off the main thread, support can be added. Please open an issue.

Configuration examples

When building MiniView, the pixels backend can be used by compiling with:

cargo run --no-default-features --features backend_pixels

When using MiniView as a library, you can use:

[dependencies.miniview]
version = "*" # replace `*` with the latest version
default-features = false 
features = ["backend_pixels"]

or

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

NB: replace * in version = "*" with any supported version.

Suggestions, Questions, Bugs

Feel free to open an issue ๐Ÿ“ฌ if you have a suggestion, a question or found a bug =).

๐ŸŽธ ๐ŸŽบ ๐ŸŽป ๐ŸŽท

miniview's People

Contributors

bors[bot] avatar dependabot-preview[bot] avatar dependabot[bot] avatar foresterre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

klimit

miniview's Issues

Add fullscreen flag to cli

Could you add something like '--fullscreen" option?
In piston WindowSettings it's .fullscreen(true)
Also it would be great to use it as crate -> it would be easier to use it for testing ;)

Thanks in advice ;)

Update dependencies

  • piston_window to (latest; contains breaking changes)
  • image to (compatible with piston_window) or 0.22

Add panning

  • e.g. with mouse or arrow keys
  • use texture transform?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.