Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.
/ AnImageViewer Public archive

An Image Viewer written in Kotlin (JavaFX)

License

Notifications You must be signed in to change notification settings

Eroica/AnImageViewer

Repository files navigation

An Image Viewer

AnImageViewer

This is an image viewer. You click on a file, and it opens a window that shows that file. Press the left or right arrow key to navigate to the next image. You can quickly compare or browse images this way.

If you click on another file, a new window opens. By default, the window size is as large as the image you open; however, never larger than half of your screen’s width. (This way you can always compare two images without them overlapping.) If you navigate to other images, the window size stays the same. In the case that the window becomes too small for the image, you can pan around by clicking and dragging over the image.

You can of course also let the image fit into the window size.

Shortcuts

Table 1. Shortcuts
Combination Function

Left Arrow

Previous image

Right Arrow

Next image

Ctrl+1

Zoom image to 100 % (no zoom)

Ctrl+2

Zoom in to 200 %

Ctrl+0

Fit image to window size

-

Fit image on screen (don’t let the window become bigger than the screen)

Ctrl+W
Ctrl+Q

Close window (alternatively to your window manager’s shortcut)

Ctrl+,

Open About window

Why An Image Viewer

When creating videos with Blender, you usually first render each frame into an individual image. I often need to look at these frames to check small details or make sure the animation feels right.

I’m now primarily using Windows 10, and the built-in Photos app has some small annoyances that make my work a little more difficult. For example, when I hold the Right arrow key to skim through each frame, the application always takes some time to load the next image. Perhaps around 0.5 seconds or something like that, but this is on a new Intel i7-9700 with SSD!

“That can’t be right,” I said to myself, and put together this image viewer. There are of course probably better alternatives on Windows, but at least this image viewer works the way that I like, and I don’t need to install additional things.

See here a quick comparison between Photos and An Image Viewer. I open the same directory and press and hold the right arrow key (pay attention to the current filename in the title bar).

Comparison

To Photos defense, I later found out that it is largely some kind of intentional (?) input delay that takes place when you press and hold a key; meaning that if you can hit the Arrow key rapidly, the application does manage to keep up with the speed. However, when skimming through video frames, I don’t want to hit the arrow keys rapidly like a maniac.

Next to that, Window’s Photos app displays transparent parts of an image as pure white which can be confusing at times. An Image Viewer shows the familiar checkerboard pattern.

When comparing two large images side-by-side, their windows can overlap awkwardly. If you tile them with Win+Left/Right the canvas size is often wrong (part of the image becomes hidden). An Image Viewer checks your screen size and will not create a window larger than half of your screen (zooming out of the image if necessary). This way if you open two images separately, you can always put them side-by-side.

But most importantly, it opens an image, and if you press and hold the Left/Right arrow key, the next image loads immediately.

How does it work

If you open an image, An Image Viewer will automatically pre-load the next and previous images. This speeds up browsing between images. I’m sure there are better approaches, but this works for me.

Installation

A jpackage-generated image is available under Releases. jpackage bundles the required JRE with the executable, so nothing else is required to run An Image Viewer.

Building

The application is written in Kotlin using JavaFX, and built by Gradle.

If you are familiar with Gradle, you can just clone this repository and execute run to execute it. Note that An Image Viewer closes immediately if there is no argument, so if you execute run you probably want to add --args "…​" as well.

License

zlib License, see LICENSE file.