Jun 16
Associate .avif files with your image viewer, on Ubuntu
Do you know that: you were scouring the Web and downloaded image graphics on website and these images end up as .avif files on your drive - but yur favourite image viewer, like viewnior, does not open it when you double-click them? Nautilus doesn't even associate these files with any image viewer nor does it identify them as being images?
Here you'll learn How to configure Linux to open .avif files as images, with your favourite image viewer. My favorite viewer is viewnior.
BUT
If this is too much hassle for you: just use Firefox or Chrome to view these files. They have support compiled in.
First: Why .avif Files Aren't Opening in Viewnior
Viewnior, like many lightweight Linux image viewers, relies on the GDK-Pixbuf library and its "loader modules" to handle image formats. Out of the box, viewnior does not support AVIF images unless the appropriate GDK-Pixbuf loader is installed. This is a common issue across many Ubuntu-based systems, as AVIF is a relatively new image format and not all distributions or applications have added support by default.
How to Enable AVIF Support in Viewnior
1. Install the Necessary Loader
- AVIF support in Viewnior requires a GDK-Pixbuf loader for AVIF. This can be provided by either
(which supplieslibavif
) or, in some cases,libpixbufloader-avif.so
(which supplieslibheif
).libpixbufloader-heif.so
- On my older Ubuntu 20.04.6 LTS libavif is not available, so I'll use libheif
- BUT, the Ubuntu 20 libheif library also has no avif support - so we need to update this library first:
- Add this PPA:
$sudo add-apt-repository ppa:strukturag/libheif
$sudo apt update - Then install the library
$ sudo apt install libheif1 heif-gdk-pixbuf - After installation, restart Viewnior and try opening an AVIF file.
2. Check Loader Installation
- To ensure the loader is installed, check for the presence of the loader file:
$ls /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/ | grep avif
- If you see
, the loader is present.libpixbufloader-avif.so
3. Set File Association (Optional)
- If AVIF files still aren't opening by default, right-click an AVIF file in your file manager, choose "Open With," and select Viewnior. You may need to add Viewnior as a custom application if it doesn't appear.
Libavif or Libheic?
So, you may ask which one is better? libpixbufloader-avif.so (from libavif12, I guess) or libheif1's loader? And what exactly is the differences between the two? Speed, compatibility?
Looking at compatibility, libavif is dedicated to the AVIF codec and the reference implementation for AVIF and is used in Chrome and other major projects. It tends to support new AVIF features (like animation) sooner and more completely than libheif. libheif is broader in scope, supporting both HEIC and AVIF.
Regarding Performance and Speed, libavif is designed specifically for AVIF and is under active development with a focus on speed and efficiency. it is generally considered faster and lighter than libheif. libheif in contrary is a more general-purpose HEIF/HEIC library with AVIF support added later. Benchmarks indicate that is is often slower than libavif.
Also, libavif has a cleaner licensing situation, with fewer patent concerns compared to libheif, which has more complex licensing due to its broader HEIF/HEIC support.