Enabling HEIF support in Nextcloud
It is actually relatively simple
- install the php imagick extension with libheif support
- enable the preview providers
For openSUSE Tumbleweed the php8-imagick package is already built with libheif support. Though the library in the distribution lacks H.256 support.
We can easily remedy that situation by using the libheif1
package from packman instead.
# cat /etc/zypp/repos.d/isv-packman.repo
[isv-packman]
enabled=1
autorefresh=1
baseurl=https://ftp.halifax.rwth-aachen.de/packman/suse/openSUSE_Tumbleweed/
type=rpm-md
gpgcheck=1
Then we can install the new libheif1
with
zypper in --from isv-packman libheif1
Afterwards you have to restart Apache or php-fpm depending on what you use.
The next step is to enable the preview provider in the configuration. As of 24.0.4 the providers enabled by default are:
'enabledPreviewProviders' => [
# default enabled providers
'OC\Preview\PNG',
'OC\Preview\JPEG',
'OC\Preview\GIF',
'OC\Preview\BMP',
'OC\Preview\XBitmap',
'OC\Preview\Krita',
'OC\Preview\WebP',
'OC\Preview\MarkDown',
'OC\Preview\MP3',
'OC\Preview\TXT',
'OC\Preview\OpenDocument',
],
So we add a new setting to config/config.php
'enabledPreviewProviders' => [
# default enabled providers
'OC\Preview\PNG',
'OC\Preview\JPEG',
'OC\Preview\GIF',
'OC\Preview\BMP',
'OC\Preview\XBitmap',
'OC\Preview\Krita',
'OC\Preview\WebP',
'OC\Preview\MarkDown',
'OC\Preview\MP3',
'OC\Preview\TXT',
'OC\Preview\OpenDocument',
# additionally enabled providers
'OC\Preview\HEIC',
'OC\Preview\TIFF',
'OC\Preview\SVG',
],
Voila your nextcloud should be able to preview images in HEIF/HEIC format. Next stop is AVIF support. The code is basically a copy of the HEIF provider but I need to learn how to hook it up in nextcloud.