Scroll to navigation

FIM(1) General Commands Manual FIM(1)

NAME

fim - Fbi (linux framebuffer imageviewer) IMproved, an universal image viewer

SYNOPSIS

fim [{options}] [--] {imagepath} [{imagepaths}]
fim --output-device {fb|sdl|ca|aa|imlib2|dumb} ...
... | fim [{options}] [--] [{imagepaths}] -
fim [{options}] [--] [{files}] - < {file_name_list_text_file}
fim --image-from-stdin [{options}] < {imagefile}
fim --script-from-stdin [{options}] < {scriptfile}
fim --help[=s|d|l|m] [{help-item} ...]

DESCRIPTION

fim is a `swiss army knife' for displaying image files. It is capable of displaying image files using different graphical devices while offering a uniform look and feel. Key bindings are customizable and specified in an initialization file. Interaction with standard input and output is possible (especially in shell scripts). An internal scripting language specialized for image viewing allows image navigation, scaling, manipulation of internal variables, command aliases, and vim-like autocommands. The internal language can be interacted with via a command line mode capable of autocompletion and history (the readline mode). Further features are display of EXIF tags, JPEG comments, EXIF rotation/orientation, load of "description files", faster load via image caching, command recording, and much more.

As a default, fim displays the specified file(s) on the detected, most convenient graphical device. This can be with SDL if running under X, an Ascii Art driver (aalib or libcaca) if running behind ssh without X forwarding, or the linux framebuffer device. Graphical file formats BMP, PCX are supported natively, while JPEG, PNG, GIF, TIFF, PPM, PGM, PBM are supported via third party libraries. Further formats are supported via external converters. For XCF (Gimp's) images, will try to use 'xcftopnm'. For FIG vectorial images, will try to use 'fig2dev'. For DIA vectorial images, will try to use 'dia'. For SVG vectorial images, will try to use 'inkscape'. For other formats will try to use ImageMagick's 'convert' executable. The converter is given 15 seconds for the conversion before a timeout.

If {imagepath} is a file, its format is guessed not by its name but by its contents. See the _file_loader variable to change this default.

If {imagepath} is a directory, therein contained files of supported formats will be loaded. If {imagepath} contains a trailing slash (/), it will be treated as a directory; otherwise this will be checked via stat(2). To change this default, see description of the _pushdir_re variable and the --no-stat-push and --recursive options.

This man page describes fim command line options and usage. See man fimrc(5) for a full specification of the fim language, commands, keysyms, autocommands, variables, aliases, examples for a configuration file and readline usage samples.

USAGE

You may invoke fim from an interactive shell and control it with the keyboard, as you would do with any image viewer with reasonable key bindings.

fim is keyboard oriented: there are no user menus or buttons available. If you need some feature or setting which is not accessible from the default keyboard configuration, you probably need a custom configuration or simply need to type a custom command. For these, you can use the internal command and configuration language.

See options --read-from-stdin, --script-from-stdin, and --image-from-stdin for more script-oriented usages.

The full commands specification is also accessible at runtime using the internal help system (typing :help).

OPTIONS

Accepted command line {options}:

--
Treat arguments after -- as filenames. Treat arguments before -- as command line options if these begin with -, and as filenames otherwise.

Enable autozoom. fim will automagically pick a reasonable zoom factor when displaying a new image (as in fbi).
Display contents of binary files (of any filetype) as these were raw 24 or 1 bits per pixel pixelmaps. Image width will not exceed the value of the _preferred_rendering_width variable. Regard this as an easter bunny option.

Display contents of files (of any filetype) as these were text. Image width will not exceed the value of the _preferred_rendering_width variable. Non-printable characters will be displayed as " ". Regard this as another easter bunny option.

Step into the first loaded directory, and then push other files.
Execute commands after reading the initialization file, just before entering the interactive mode. No semicolon (;) is required at the end of commands. Do not forget quoting commands in a manner suitable to your shell. So -c next is fine as it is. A more complicated example, with quotings: -c '*2;2pan_up;display;while(1){align "bottom";sleep "1" ; align "top"}' (with the single quotes) tells fim to: double the displayed image size, pan twice up, display the image, and finally do an endless loop consisting of bottom and top aligning, alternated.

Similar to the --execute-commands option, but execute commands earlier, just before reading the initialization file.

For example, -C '_scale_style=" "' starts fim no auto-scaling.

Framebuffer device to use. Default is the one your vc is mapped to (as in fbi).
Dump to stdout language reference help and quit.
Dump default configuration (the one hardcoded in the fim executable) to standard output and quit.
Execute scriptfile after the default initialization file is read, and before executing --execute-commands commands.
Specify an alternative system wide initialization file (default: /usr/local/etc/fimrc), to be read prior to any other configuration file.

Similar to the --execute-commands option, but execute commands after exiting the interactive mode, just before terminating the program.
Print program invocation help, and exit. Depending on the option, output can be: short, descriptive, long from man, or complete man. If further arguments follow, individual help messages will be shown instead.
Execute any command bound (via the bind command) to a specified keysym at startup. A keysym can be prefixed by a repetition count number. You can specify the option multiple times to simulate multiple keystrokes. See man fimrc(5) for a list of keysyms and the use of bind.
Input one or more keyboard characters at program startup (simulate keyboard presses). This option can be specified multiple times. Each additional time (or if the string is empty), a press of Enter (ASCII code 0x0D) key is prepended. Examples: -K '' simulates press of an Enter; -K ':next;' activates the command line and enter "next;" without executing it; -K ":next;" -K "next" executes "next", stays in the command line and enter keys "next"; -K ":next;" -K "" -K "next" executes "next", leaves the command line, and executes in sequence any command bound to keys 'n', 'e', 'x', 't'.
Load image descriptions from file filename. Each line begins with the basename of an image file, followed by a Tab character (or a different character if specified via --image-descriptions-file-separator), then the description text. The description text is copied into the i:_comment variable of the image at load time, overriding the comment possibly loaded from the file (e.g. JPEG, PNG or TIFF comment). If a '@' followed by and identifier {var} is encountered, and i:{var} is set, its value is substituted here. If "@#" is encountered, the remainder of the description line is ignored. Special comment lines like "#!fim:var=val" lead i:var to be assigned value val (unquoted) at image loading time (cached variable); i:var will not be assigned if var starting with underscore ('_'). Special comment lines like "#!fim:+=val" add val to current description. Special comment lines like "#!fim:^=val" set val to be the base of each description. Special comment lines like "#!fim:!=" reset all cached variables. Special comment lines like "#!fim:/=dir" prepend dir to each file's basename. Special comment lines like "#!fim:\=dir" prepend dir to each file's name. Special description text (to be associated to an image) begins with markers: with "#!fim:=", the last description line is reused; with "#!fim:+", what follows is appended to the last description line; with "#!fim:^", what follows is prepended to the last description line; with "#!fim:s/f/t", the last description line will be used after substitution of occurrences of substring f with string t (f and t cannot contain newlines or a '/'). If val is empty that variable is unset. These variables are stored also in an internal index used by the limit command. This option sets _caption_over_image=2, so that a caption is displayed over the image. A description file beginning with "#!fim:desc" can be loaded without specifying this switch.
A character to be used as a separator between the filename and the description part of lines specified just before a --load-image-descriptions-file.
Read one single image from the standard input (the image data, not the filename). May not work with all supported file formats. In the image list, this image takes the special name "<STDIN>".

Set those files specified in filename (see --load-image-descriptions-file for the file format) as marked (see the list command).

Name of the video mode to use video mode (must be listed in /etc/fb.modes). Default is not to change the video mode. In the past, the XF86 config file (/etc/X11/XF86Config) used to contain Modeline information, which could be fed to the modeline2fb perl script (distributed with fbset). On many modern xorg based systems, there is no direct way to obtain a fb.modes file from the xorg.conf file. So instead one could obtain useful fb.modes info by using the (fbmodes (no man page AFAIK)) tool, written by bisqwit. An unsupported mode should make fim exit with failure. But it is possible the kernel could trick fim and set a supported mode automatically, thus ignoring the user set mode.
No personal initialization file will be read (default is ~/.fimrc) at startup.
No system wide initialization file will be read (default is /usr/local/etc/fimrc) at startup.
No internal default configuration at startup (uses internal variable _no_default_configuration). Will only provide a minimal working configuration.
With internal command line mode disabled.
Do not save execution history at finalization (uses internal variable _save_fim_history).
Do not load execution history at startup.
Do not load or save execution history at startup.
Read commands from stdin before entering in interactive mode.
Will use the specified device as fim video output device, overriding automatic checks. The available devices depend on the original configuration/compilation options, so you should get the list of available output devices issuing fim --version. The fb option selects the Linux framebuffer. Presence of option S (e.g. fb=S) makes framebuffer initialization more picky: it will not tolerate running in a screen session. The ca option (coloured Ascii Art) can be specified as ca[={['w']}] ; if supplied, 'w' selects windowed mode, provided libcaca is running under X; by default (or with 'W'), windowed mode is being turned off internally during initialization by unsetting the DISPLAY environment variable. The aa (monochrome Ascii Art) option can be specified as aa[={['w'|'W']}]; if supplied, 'w' selects windowed mode, provided aalib is running under X; by default (or with 'W'), windowed mode is being turned off internally during initialization by unsetting the DISPLAY environment variable. Please note that the readline (internal command line) functionality in ca and aa modes is limited. The sdl option (graphical windowed mode) may be specified as sdl={['w']['m']['r']['h']['W']['M']['R']['H'][width[:height]]['%']}, where width and height are integer numbers specifying the desired resolution (if height not specified, it takes the value of width); the 'w' character requests windowed mode; the 'm' character requests mouse pointer display; the 'h' character requests help grid map draw (option can be repeated); the 'r' character requests support for window resize; the '%' character requests to treat width and height as percentage of possible window resolution. The same letters uppercase request explicit negation of the mentioned features. The imlib2 option requests imlib2 and is unfinished -- do not use it. The dumb test mode is not interactive.

Use the specified offset (in bytes) for opening the specified files. If :upper-offset is specified, further bytes until upper-offset will be probed. If +offset-range is specified instead, that many additional bytes will be probed. Use this option to search damaged file systems for image files.
Specify a shell command with {cmd-filter-pipeline}. If the current filename matches "^[/A-Za-z0-9_.][/A-Za-z0-9_.-]*$", it will be substituted to any occurrence of '{}'. The resulting command output is assumed to be file data, which will be read and displayed. This works by setting the internal _pread_cmd variable (empty by default).
Enable textreading mode. This has the effect that fim will display images scaled to the width of the screen, and aligned to the top. If the images you are watching are text pages, all you have to do to get the next piece of text is to press space (in the default key configuration, of course).
Set scroll steps for internal variable _steps (default is 20%).
Interruptible slideshow mode. Wait for {number} of seconds (assigned to the _want_sleep_seconds variable) after each image. Implemented by executing reload; i:fresh=1; while(_fileindex <= _filelistlen-_loop_only_once){sleep _want_sleep_seconds; next;} sleep _want_sleep_seconds; as a first command. Can be interrupted by : or Esc. The other keys will execute accordingly to their function but will not interrupt the slideshow. Like in fbi, this will cycle forever, unless --once is specified.
Perform a quick sanity check, just after the initialization, and terminate.
fim Use an ASCII Art driver. If present, use either of libcaca (coloured), or aalib (monochrome). For more, see (man fimrc), (info aalib) or (apropos caca)). If no ASCII Art driver was enabled at compile time, fim will not display any image at all.
The terminal will be used as virtual terminal device file (as in fbi). See (chvt (1)), (openvt (1)) for more info about this. Use (con2fb (1)) to map a terminal to a framebuffer device.

Reverse files list before browsing (can be combined with the other sorting options).
Sort files list before browsing according to full filename.
Sort files list before browsing according to file basename's.
Sort files list before browsing according to file modification time.
Sort files list before browsing according to file size.
Randomly shuffle the files list before browsing (seed depending on time() function).
Pseudo-random shuffle the files list before browsing (no seeding).
Be verbose: show status bar.
Load files verbosely (repeat option to increase verbosity).
Load font verbosely (sets _fbfont_verbosity).
Execute interpreter verbosely (Sets immediately _debug_commands="ackC" if specified once, _debug_commands="ackCi" if specified twice).
Print to stdout program version, compile flags, enabled features, linked libraries information, supported filetypes/file loaders, and then exit.
Scale the image according to the screen width.
Do not scale the images after loading (will set '_scale_style=" "';).
Resize the window size (if supported by the video mode) to the image size. Don't use this with other image scaling options.
Sets _push_checks=0 before initialization, thus disabling file/dir existence checks with stat(2) at push push time (and speeding up startup).
Scale the image according to the screen height.
All the characters that you type are recorded in the file {scriptout}, until you exit fim. This is useful if you want to create a script file to be used with "fim -c" or ":exec" (analogous to Vim's -s and ":source!"). If the {scriptout} file exists, it will be not touched (as in Vim's -w).
Read file list from a file: each line one file to load (similar to --read-from-stdin; use --read-from-stdin-elds to control line breaking).

-, --read-from-stdin
Read file list from stdin: each line one file to load; use with --read-from-stdin-elds to control line breaking).

Note that these the three standard input reading functionalities (-i,-p and -) conflict : if two or more of them occur in fim invocation, fim will exit with an error and warn about the ambiguity.

See the section INVOCATION EXAMPLES below to read some useful (and unique) ways of employing fim.

Specify an endline delimiter character for breaking lines read via -/--read-from-stdin/--read-from-file (which shall be specified after this). Line text before the delimiter will be treated as names of files to load; the text after will be ignored. This is also useful e.g. to load description files (see --load-image-descriptions-file) as filename list files. Default is the newline character (0x0A); to specify an ASCII NUL byte (0x00) use ''.

Align images to the top border (by setting '_autotop=1' after initialization).
Quiet execution mode. Sets _display_status=0;_display_busy=0;.

Set resolution specification in pixels. Supported by SDL only (will be appended to --output-device argument).
Push files/directories to the files list recursively. The expression in variable _pushdir_re (default: ".(JPG|PNG|GIF|BMP|TIFF|TIF|JPEG|JFIF|PPM|PGM|PBM|PCX|WEBP)$") lists extensions of filenames which will be loaded in the list. You can overwrite its value by optionally passing an expression {exp} here as argument. If starting with '+' or '|', the expression following will be appended to it.
Do not load via external converter programs: only use built-in file decoders.
Push files/directories to the files list recursively, in background during program execution. Any sorting options will be ignored. Experimental feature, unfinished.
Add {dir} to the shadow directory list. Then 'scale "shadow"' will temporarily substitute the image being displayed with that of the first same-named file located under a shadow directory. Useful to browse low-res images, but still being able to quickly view the hi-res original residing in a shadow directory. This works as intended as long as unique filenames are involved.
-/ {pattern}, --/ {pattern}
After startup jump to pattern; short for -c '/'.
--// {pattern}
After startup jump to pattern; as -c '/' but with search on the full path (with _re_search_opts="f").
-1, --once
If running --slideshow, loop only once (as in fbi).

PROGRAM RETURN STATUS

The program return status is 0 on correct operation; 252 on unsupported device specification; 248 on bad input; 255 on a generic error; 42 on a signal-triggered program exit; or a different value in case of an another error.
The return status may be controlled by the use of the quit command.

COMMON KEYS AND COMMANDS

The following keys and commands are hardcoded in the minimal configuration. These are working by default before any config loading, and before the hardcoded config loading (see variable _fim_default_config_file_contents).

n goto '+1f'
p goto '-1f'
+ magnify
- reduce
h pan 'left'
l pan 'right'
k pan 'up-'
j pan 'down+'
q quit You can type a number before a command binding to iterate the assigned command: 3k 3pan 'up-'
: enter command line mode :{number} jump to {number}^th image in the list :^ jump to first image in the list :$ jump to last image in the list :*{factor} scale the image by {factor} :{scale}% scale the image to the desired {scale} :+{scale}% scale the image up to the desired percentage {scale} (relatively to the original) :-{scale}% scale the image down to the desired percentage {scale} (relatively to the original) /{regexp} entering the pattern {regexp} (with /) makes fim jump to the next image whose filename matches {regexp} /*.png$ entering this pattern (with /) makes fim jump to the next image whose filename ends with 'png' /png a shortcut for /.*png.* 2,4 stdout '{}' print three filenames to standard output. !{syscmd} executes the {syscmd} quoted string as an argument to the "system" fim command. You can visualize all of the default bindings invoking fim --dump-default-fimrc | grep bind . You can visualize all of the default aliases invoking fim --dump-default-fimrc | grep alias .

The Return vs. Space key thing can be used to create a file list while reviewing the images and use the list for batch processing later on.

All of the key bindings are reconfigurable; see the default fimrc file for examples on this, or read the complete manual: the FIM.TXT file distributed with fim.

AFFECTING ENVIRONMENT VARIABLES

FBFONT		(just like in fbi) a Linux consolefont font file.
If using a gzipped font, the zcat program will be used to uncompress it (via execvp(3)).
If not specified, the following files will be probed and the first existing will be selected:
/usr/share/consolefonts/Lat15-Terminus16.psf.gz
/usr/share/kbd/consolefonts/cp866-8x16.psf.gz
/usr/share/consolefonts/Uni3-TerminusBoldVGA14.psf.gz
/usr/lib/kbd/consolefonts/lat9-16.psf.gz
/usr/share/consolefonts/lat1-16.psf
/usr/share/consolefonts/lat1-16.psf.gz
/usr/share/consolefonts/lat1-16.psfu.gz
/usr/share/kbd/consolefonts/lat1-16.psf
/usr/share/kbd/consolefonts/lat1-16.psf.gz
/usr/share/kbd/consolefonts/lat1-16.psfu.gz
/usr/lib/kbd/consolefonts/lat1-16.psf
/usr/lib/kbd/consolefonts/lat1-16.psf.gz
/usr/lib/kbd/consolefonts/lat1-16.psfu.gz
/lib/kbd/consolefonts/lat1-16.psf
/lib/kbd/consolefonts/lat1-16.psf.gz
/lib/kbd/consolefonts/lat1-16.psfu.gz
/lib/kbd/consolefonts/Lat2-VGA14.psf.gz
/lib/kbd/consolefonts/Lat2-VGA16.psf.gz
/lib/kbd/consolefonts/Lat2-VGA8.psf.gz
/lib/kbd/consolefonts/Uni2-VGA16.psf.gz
/usr/share/consolefonts/default8x16.psf.gz
/usr/share/consolefonts/default8x9.psf.gz
/usr/share/consolefonts/Lat15-Fixed16.psf.gz
/usr/share/consolefonts/default.psf.gz
fim://
If the special fim:// string is specified, a hardcoded font will be used.
FBGAMMA		(just like in fbi) gamma correction (applies to dithered 8 bit mode only). Default is 1.0.
FRAMEBUFFER	(just like in fbi) user set framebuffer device file (applies only to the fb mode).
If unset, fim will probe for /dev/fb0.
TERM		(only in fim) will influence the output device selection algorithm, especially if $TERM=="screen".
SSH_TTY	if set and no output device specified, give precedence to ca, then aa (if present).
DISPLAY	If this variable is set, then the sdl driver will be probed by default.

COMMON PROBLEMS

fim needs read-write access to the framebuffer devices (/dev/fbN or /dev/fb/N), i.e you (our your admin) have to make sure fim can open the devices in rw mode. The IMHO most elegant way is to use pam_console (see /etc/security/console.perms) to chown the devices to the user logged in on the console. Another way is to create some group, chown the special files to that group and put the users which are allowed to use the framebuffer device into the group. You can also make the special files world writable, but be aware of the security implications this has. On a private box it might be fine to handle it this way through.

If using udev, you can edit: /etc/udev/permissions.d/50-udev.permissions and set these lines like here:
# fb devices
fb:root:root:0600
fb[0-9]*:root:root:0600
fb/*:root:root:0600

fim also needs access to the linux console (i.e. /dev/ttyN) for sane console switch handling. That is obviously no problem for console logins, but any kind of a pseudo tty (xterm, ssh, screen, ...) will not work.

INVOCATION EXAMPLES

fim --help -R -B
# get help for options -R and -B

fim media/
# load files from the directory media/

fim -R media/ --sort
# open files found by recursive traversal of directory media, then sorting the list

find /mnt/media/ -name *.jpg | fim -
# read input files list from standard input

find /mnt/media/ -name *.jpg | shuf | fim -
# read input files list from standard input, randomly shuffled

cat script.fim | fim -p images/*
# read a script file script.fim from standard input before displaying files in the directory images

scanimage ... | tee scan.ppm | fim -i
# read the image scanned from a flatbed scanner as soon as it is read

h5topng -x 1 -y 2 dataset.hdf -o /dev/stdout | fim -i
# visualize a slice from an HDF5 dataset file

fim * > selection.txt
# output the file names marked interactively with the 'list "mark"' command in fim to a file

fim * | fim -
# output the file names marked with 'm' in fim to a second instance of fim, in which these could be marked again

fim -c 'pread "vgrabbj -d /dev/video0 -o png";reload'
# display an image grabbed from a webcam

fim -o aa -c 'pread "vgrabbj -d /dev/video0 -o png";reload;system "fbgrab" "asciime.png"'

# if running in framebuffer mode, will save a png screenshot with an ASCII rendering of an image grabbed from a webcam

fim -c 'while(1){pread "vgrabbj -d /dev/video0 -o png";reload;sleep 1;};'


# will display a sequence of images grabbed from a webcam; circa 1 per second

NOTES

This manual page is neither accurate nor complete. In particular, issues related to driver selection shall be described more accurately. Also the accurate sequence of autocommands execution, variables application is critical to understanding fim, and should be documented. The filename "<STDIN>" is reserved for images read from standard input (view this as a limitation), and thus handling files with such name may incur in limitations. The SDL driver is quite inefficient, for a variety of reasons. In particular, its interaction with the readline library can be problematic (e.g.: when running in sdl mode without a terminal). This shall be fixed.

BUGS

fim has bugs. Please read the BUGS file shipped in the documentation directory to discover the known ones. There are also inconsistencies in the way the internal command line works across the different graphical devices.

FILES

/usr/local/share/doc/fim
The directory with fim documentation files.
/usr/local/etc/fimrc
The system wide fim initialization file (executed at startup, after executing the hardcoded configuration).
~/.fimrc
The personal fim initialization file (executed at startup, after the system wide initialization file).
~/.fim_history
File where to load from or save. See (man fimrc(5), man readline(3)).
~/.inputrc
If fim is built with GNU readline support, it will be susceptible to chages in the user set ~/.inputrc configuration file contents. For details, see (man readline(3)).

SEE ALSO

Other fim man pages: fimgs(1), fimrc(1).
Conversion programs: convert(1), dia(1), xcftopnm(1), fig2dev(1), inkscape(1).
Related programs: fbset(1), con2fb(1), vim(1), mutt(1), exiftool(1), exiftags(1), exiftime(1), exifcom(1), fbi(1), fbida(1), feh(1), fbgrab(1).
Related documentation: fbdev(4), vcs(4), fb.modes(8), fbset(8), setfont(8).

AUTHOR

Michele Martone <dezperado _CUT_ autistici _CUT_ org> is the author of fim, "fbi improved". 

COPYRIGHT

Copyright (C) 2007-2022 Michele Martone <dezperado _CUT_ autistici _CUT_ org> (author of fim)

Copyright (C) 1999-2004 Gerd Hoffmann <kraxel _CUT_ bytesex.org> is the author of "fbi", upon which fim was originally based.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

(c) 2007-2022 Michele Martone