This post/rant may get big enough that I thought it could stand alone.

After uploading all of my photos, I thought that I would pre-generate all of the image previews so that I'd have them all ready when I want to view them. It doesn't take too long to generate them on the fly, but it's long enough on my cheap hosting that I wanted to give it a shot.

Initial Setup and Generation

First, I needed to add the Preview Generator app to my install. (Here's the github link)

Then, the magic:

docker-compose exec --user www-data app php occ preview:generate-all -vvv

It ran for a while...and then failed for some mysterious reason. Perhaps this or this? I couldn't get it figured out, but if I run the 'generate-all' command over and over, I found that it would eventually finish.

Success! Or was it? The previews nearly doubled the amount of used disk space! Ok, let's just delete them... Oh wait, there's no straightforward way to do that!

Deleting the Previews

Back to google... Fortunately, I wasn't the only one to run into this problem. Lots of suggestions for improvment (none of which appear to have been implemented), mixed with some useful information. The good stuff:

sudo rm -rf /mnt/foo/nextcloud/docker/nextcloud/data/appdata_.../preview/*

Since I did this outside of the nextcloud app, I also have to kick it to rescan and pick up the changes:

docker-compose exec --user www-data app php occ files:scan-app-data

Making Things Better

This post is an absolute gold mine of information about how to get reasonable previews without wasting so much disk space. I considered smaller values for some of this, but ultimately decided to use the values from the post.

docker-compose exec --user www-data app php occ config:app:set previewgenerator squareSizes --value="32 256"
docker-compose exec --user www-data app php occ config:app:set previewgenerator widthSizes  --value="256 384"
docker-compose exec --user www-data app php occ config:app:set previewgenerator heightSizes --value="256"
docker-compose exec --user www-data app php occ config:system:set preview_max_x --value 2048
docker-compose exec --user www-data app php occ config:system:set preview_max_y --value 2048
docker-compose exec --user www-data app php occ config:system:set jpeg_quality --value 60
docker-compose exec --user www-data app php occ config:app:set preview jpeg_quality --value="60"

And Now: Rebuild

We've deleted all the previews, completed our rescan, and set the desired values. Now, just generate all the previews again:

docker-compose exec --user www-data app php occ preview:generate-all -vvv

Again, it runs for a while, slows down and occasionally fails. Just re-run until completed.

Previous Post Next Post