I was having some performance problems with image previews in Nextcloud. Every time I entered the gallery or image folders CPU usage would shoot through the roof and eventually crash the MySQL service, bringing down the service entirely.
This can happen with lots of images on your instance if you are hosting it on an underpowered machine or in my case, a small VPS with many other services in contention for resources.
There is an easy solution however.
There is actually a very quick tweak you can make to stop the previews being generated at full resolution which will stop the problem, and still allow you to download the image at original quality.
Within your Nextcloud installation directory is config/config.php
My path is /var/www/nextcloud/config/config.php
Yours may differ depending on where you set it up.
Save and close your editor.
Now reload your web-server and you are done!
This will limit the size of the previews that are generated and stop the performance problems associated with the generation.