Nextcloud: Install Preview Generator

This installation guide is tested with Nextcloud up to version 16.x and Preview Generator App up to version 2.x.

Tested and working file formats

avi, doc, bmp, gif, jpg, md, mkv, mp3, mp4, odp, ods, odt, pdf, png, psd, svg, tif, ttf, txt, xls.

Update your system

apt upgrade && apt -y update

Install the Preview Generator App

of the Nextcloud app store: apps.nextcloud.com/apps/previewgenerator

Install LibreOffice

apt install libreoffice libreoffice-l10n-de libreoffice-help-de

Install ffmpeg, ImageMagick and Ghostscript

apt install ffmpeg imagemagick ghostscript

Add preview providers

Append to /var/www/nextcloud/config/config.php

'preview_libreoffice_path' => '/usr/bin/libreoffice',
'enable_previews' => true,
'enabledPreviewProviders' =>
 array (
    0 => 'OC\\Preview\\TXT',
    1 => 'OC\\Preview\\MarkDown',
    2 => 'OC\\Preview\\OpenDocument',
    3 => 'OC\\Preview\\PDF',
    4 => 'OC\\Preview\\MSOffice2003',
    5 => 'OC\\Preview\\MSOfficeDoc',
    6 => 'OC\\Preview\\Image',
    7 => 'OC\\Preview\\Photoshop',
    8 => 'OC\\Preview\\TIFF',
    9 => 'OC\\Preview\\SVG',
   10 => 'OC\\Preview\\Font',
   11 => 'OC\\Preview\\MP3',
   12 => 'OC\\Preview\\Movie',
   13 => 'OC\\Preview\\MKV',
   14 => 'OC\\Preview\\MP4',
   15 => 'OC\\Preview\\AVI',
 ),

Create .cache folder

on ISPConfig servers in the home directory of virtual host to prevent

unable to create directory '/var/www/clients/client1/web1/.cache/dconf': Operation not permitted. dconf will not work properly

Only necessary for for office documents like .ods and .odt.

Fix PolicyMap for ImageMagick

to prevent ImagickException: not authorized error. Necessarry for PDF files.

First Run

sudo -u www-run php /var/www/nextcloud/occ preview:generate-all -vvv

Add Cronjob

crontab -u www-run -e
*/10 * * * * php /var/www/nextcloud/occ preview:pre-generate -vvv

Finished

Jahman!

See also

Source code in /var/www/html/lib/private/Preview/*.php