sdl_img
A simple image viewer based on SDL2 and stb_image
A lightweight image viewer built on SDL2
Sdl_img is a C image viewer using stb_image that works as a drop in replacement while adding power user features.
Design goals and everyday use
sdl_img is a simple image viewer built on SDL2 and the stb_image single header library, with the animated GIF extension that stb_image suggests. The author calls it simple because it covers the normal and expected behavior most people want, so it works as a drop in replacement for a default viewer. At the same time it carries many extra and unusual features aimed at power users, especially on Linux and Unix systems and for people comfortable at the terminal. The stated goals are straightforward. The first is to implement features the author always wanted in an image viewer. The second is to keep the code relatively simple, short, and readable. The third is learning, practice, and fun. The fourth is to stay reasonably fast and lightweight rather than chase raw speed. You can launch it with no arguments, in which case it opens in a file selection mode since no image was given. You can also pass a filename directly, or use the f flag to start in full screen mode. When you open a file, the viewer loads that image and every other file with a recognized image extension in the same directory, so moving through a folder of pictures is immediate. On Windows the same binary works, and the README suggests associating file types with sdl_img.exe so double clicking an image opens it directly.
Controls and navigation
Navigation follows keys that map to how people already think about moving through images. Left or Up goes to the previous image, and Right or Down goes to the next one. Space also advances to the next image, while Control and Space steps back to the previous one. When an image is zoomed in, Control combined with a direction moves between images even though a plain direction key would pan instead. The plus and minus keys zoom in and out. These bindings are documented in a table in the README along with a longer list of actions. The alphabetical ordering of files in a directory matters here, and the README links to the project's own string comparison source so the sort order behaves the way a person expects rather than a strict byte compare. Beyond single image viewing, sdl_img offers several named modes that set it apart from a bare viewer. There is a thumbnail mode for scanning a folder visually, a library mode for managing sets of images, a four image mode that shows several at once, and GIF controls that include a scrub bar for animated files. The author notes that a screenshot cannot really show the GIF scrub bar, and points to a short video demonstration for that feature. A file open dialog rounds out the basic interactions.
Getting the code and builds
The source lives on GitHub, and the README links to both the repository and the latest release page there. A Coverity Scan build status badge appears at the top of the README, which suggests the author cares about static analysis and keeps the code in a state that passes that scan. The project is small and self contained, built around SDL2 and stb_image, so building it does not pull in a large dependency tree. The gallery section of the README shows screenshots of the normal view, thumbnail mode, GIF controls, library mode, four image mode, and the open file dialog, which together give a clear picture of the interface without installing anything. Because the code is meant to be short and readable, someone who wants a specific behavior can study the source and change it. The license is MIT, which permits both personal and commercial use as long as the copyright notice is kept. For most Linux and Unix users the terminal friendly design is the main draw, since the viewer can be scripted and controlled with the keyboard in ways that many graphical viewers do not support. The combination of a tiny dependency footprint, readable code, and the extra modes makes it a practical choice for people who live in the terminal but still need to look at images often.
Editorial conclusion
The program is published under the MIT license and is written in C.
Community notes