How to generate image previews in Nextcloud with Imaginary with Docker

How to generate image previews in Nextcloud with Imaginary with Docker

Official documentation

The preview generator app is resource heavy and the default Nextcloud preview generator limited. However an external preview generation service is easily implemented and configured for quick on the fly previews thanks to the Imaginary docker image made available by the Nextcloud AIO folks.

  • install docker on host
  • create docker stack
    • or create a docker-compose.yaml in place and execute in docker
  • edit Nextcloud config.php to enable preview generation with the imaginary service adding a preview array of file types for preview

Docker stack

or create a docker-compose.yaml in place

services:
  imaginary:
    image: ghcr.io/nextcloud-releases/aio-imaginary:latest
    ports:
      - "8088:8088"
    environment:
      - PORT=8088
    command: -concurrency 50 -enable-url-source

Configure Nextcloud

Edit config.php manually or issue command in host to enable preview generation adjusting the value to your docker service IP-address including the configured docker port:
<http://imaginary.docker.service.ip:port>

occ config:system:set preview_imaginary_url --value="http://127.0.0.1:8088"

and edit config.php manually or issue command in host to enable imaginary

occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\Imaginary"

Add an array of preview file types if desired.

Example config.php including preview array of file types

  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\Imaginary',
    1 => 'OC\\Preview\\OpenDocument',
    2 => 'OC\\Preview\\ImaginaryPDF',
    3 => 'OC\\Preview\\MSOfficeDoc',
    4 => 'OC\\Preview\\MarkDown',
    5 => 'OC\\Preview\\MP3',
    6 => 'OC\\Preview\\MP4',
    7 => 'OC\\Preview\\AVI',
    8 => 'OC\\Preview\\Movie',
    9 => 'OC\\Preview\\MKV',
    10 => 'OC\\Preview\\XCF',
  ),
  'preview_imaginary_url' => 'http://192.168.2.16:8088',
1 Like