How to generate image previews in Nextcloud with Imaginary with Docker
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.yamlin place and execute in docker
- or create a
- edit Nextcloud
config.phpto enable preview generation with the imaginary service adding a preview array of file types for preview if desired.
Docker stack
or create a docker-compose.yaml in place and execute in docker
services:
imaginary:
image: ghcr.io/nextcloud-releases/aio-imaginary:latest
ports:
- "9000:9000"
environment:
- PORT=9000
command: -concurrency 50 -enable-url-source
restart: always
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://imaginary.docker.service.IP:9000"
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://imaginary.docker.service.IP:9000',