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
timg-1.6.3.tar.gz(1.2 MiB)
sha25659c908867f18c81106385a43065c232e63236e120d5b2596b179ce56340d7b01
upstream: https://github.com/hzeller/timg/archive/v1.6.3.tar.gz
archive copy: sources-2/graphics--timg-1.6.3.tar.gz
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:
-DTIMG_VERSION_FROM_GIT=Off— Takes the version from the project’s ownCMakeLists.txtinstead of runninggit describe, which on a release archive would need git and find no repository.-DWITH_GRAPHICSMAGICK=On— The general image loader, through graphicsmagick’s Magick++, which opens most formats the specific loaders below do not.-DWITH_STB_IMAGE=On,-DWITH_QOI_IMAGE=On— The self-contained STB loader, the fallback for common formats, and the QOI format. Neither has a port: each uses its header fromthird_party/when no system copy is found.-DWITH_TURBOJPEG=On— Fast JPEG loading through libjpeg-turbo. The same branch requires libexif, which reads the orientation tag, so a photo taken sideways is turned upright.-DWITH_RSVG=On— SVG through librsvg and cairo.-DWITH_POPPLER=On— PDF through poppler’s GLib binding. Each page is a frame, so--frame-offsetand--frameschoose the pages.-DWITH_LIBSIXEL=On— Sixel output through libsixel, for terminals that speak neither graphics protocol.-DWITH_VIDEO_DECODING=On— Video and animated formats through ffmpeg’s libraries. With it on, every image is also scaled through libswscale instead of STB’s resizer.-DWITH_VIDEO_DEVICE=On— Reading from video devices through libavdevice, which makestimg /dev/video0a live camera preview in the terminal.-DWITH_OPENSLIDE_SUPPORT=Off— No whole-slide microscopy formats; OpenSlide is not a port. Upstream’s default, named.
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.