Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

306.1. timg-1.6.3

Terminal image and video viewer

Version 1.6.3, release 2
Shelf graphics — Graphics applications: painting, vector, photo development and management, image viewers, screenshot and image optimisers
Phase 44_apps (Applications), 221 of 422 in build order
Licence GPL-2.0-only
Homepage https://github.com/hzeller/timg
Build time 0.9 SBU
Installed size 547.2 KiB in 4 files
Recipe ports/core/graphics/timg/kpkgbuild

About

timg shows images, animations, PDF pages and video in a terminal. It draws with the kitty or iTerm2 graphics protocols or sixel where the terminal speaks one, and with coloured Unicode block characters everywhere else. Its desktop entry opens PNG, JPEG, GIF, WebP, BMP and TIFF in the session’s terminal, Konsole, which draws them as pictures.

Why it is in KDOS

The comment above it in script/phases/44_apps/packages.d/graphics.txt:

Adds video frames to chafa's picture path and is the entry the file managers' previewers call; it draws a PDF's pages through poppler's glib binding. A photograph in a message is drawn by the same program that draws one in a file manager.

Sources

Dependencies

Depends on: cmake, pkgconf, libjpeg-turbo, libexif, librsvg, cairo, poppler, libsixel, ffmpeg, libdeflate, zlib, graphicsmagick.

Required by: no port names it.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/44_apps/phase.env && kpkg install timg'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/graphics/timg.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/graphics/timg
echo '59c908867f18c81106385a43065c232e63236e120d5b2596b179ce56340d7b01  timg-1.6.3.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/timg
SRC=$SRC_ROOT/timg-1.6.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf timg-1.6.3.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

mkdir -p build && cd build
cmake .. \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DTIMG_VERSION_FROM_GIT=Off \
	-DWITH_GRAPHICSMAGICK=On \
	-DWITH_STB_IMAGE=On \
	-DWITH_QOI_IMAGE=On \
	-DWITH_TURBOJPEG=On \
	-DWITH_RSVG=On \
	-DWITH_POPPLER=On \
	-DWITH_LIBSIXEL=On \
	-DWITH_VIDEO_DECODING=On \
	-DWITH_VIDEO_DEVICE=On \
	-DWITH_OPENSLIDE_SUPPORT=Off
make
make DESTDIR=$PKG install

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/timg.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Image Viewer (timg)
GenericName=Image Viewer
Comment=Pictures and video in a terminal
Exec=timg %F
Icon=image-x-generic
Terminal=true
NoDisplay=true
Categories=Graphics;Viewer;
MimeType=image/png;image/jpeg;image/gif;image/webp;image/bmp;image/tiff;
Keywords=image;picture;photo;view;sixel;kitty;timg;
EOF
chmod 644 "$PKG/usr/share/applications/timg.desktop"

The switches, and why each is set:

Every On here is upstream’s default, named. Each option that is on and needs a library finds it with a required pkg_check_modules, so a missing one stops configure rather than building a timg that cannot open that format; STB and QOI need none.

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/timg, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf timg-1.6.3-2.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/timg, and runs the triggers its paths call for.

Contents

Installed programs: timg.

Installed directories: /usr/share/licenses/timg.

Short descriptions

timg A terminal image and video viewer

Notes

The desktop entry is written in build.sh (see Desktop entries belong to the port). It is Terminal=true, so the launcher opens it in Konsole, which draws pictures, and its name is Image Viewer (timg). It is NoDisplay=true: with no file timg prints its usage and exits, so it is offered under Open With for its six types and has no Start row.