NextCloud – Improve Images preview and reduce CPU load

Here’s a quick guide on how to improve images preview and reduce CPU usage of NextCloud while browsing your directories containing images.

First you’ll need to install the following NextCloud App: Preview Generator

Then you’ll have to run the following “occ” command in order to optimize the size of the generated thumbnails:

php ./occ config:app:set previewgenerator squareSizes --value="32 256"
php ./occ config:app:set previewgenerator widthSizes  --value="256 384"
php ./occ config:app:set previewgenerator heightSizes --value="256"
php ./occ config:system:set preview_max_x --value 2048
php ./occ config:system:set preview_max_y --value 2048
php ./occ config:system:set jpeg_quality --value 60
php ./occ config:app:set preview jpeg_quality --value="60"

Once the Preview Generator app has been installed and activated, execute the following “ooc” command:

php ./occ preview:generate-all

This will scan all of your files and will genarate thumbnails. You can add the above command to your nextcloud user’s cron to be executed every 10 minutes eg:

*/10 * * * * php /path/to/your/nextcloud/occ preview:generate-all