Stars: 411
Forks: 57
Pull Requests: 112
Issues: 297
Watchers: 17
Last Updated: 2023-09-11 10:28:31
Nextcloud app to do preview generation in the background.
License: GNU Affero General Public License v3.0
Languages: PHP
Nextcloud app that allows admins to pre-generate previews. The app listens to edit events and stores this information. Once a cron job is triggered it will start preview generation. This means that you can better utilize your system by pre-generating previews when your system is normally idle and thus putting less load on your machine when the requests are actually served.
The app does not replace on demand preview generation so if a preview is requested before it is pre-generated it will still be shown.
./occ preview:generate-all
once after installation. ./occ preview:pre-generate
If a preview already exists at step 2 then requesting it is really cheap. If not it will be generated. Depending on the sizes of the files and the hardware you are running on the time this takes can vary.
Loop over all files and try to generate previews for them. If one or multiple user ids are supplied
it will just loop over the files of those users. You can also limit the generation to one or more
paths using --path="/[username]/files/[folder path]"
, e.g. --path="/alice/files/Photos"
. Note that
all given user_ids are ignored if at least one path is specified.
Do the actual pregeneration. This means only for new or modified files (since the app was enabled or the last pregeneration was done).
Preview generation can be a very long running job. Thus we need a system that does not time out.
Yes this happens when the pre-generate
command crashes. No worries the lock
will be released after 30 minutes of inactivity from the app. So go grab a cookie.
Follow these instructions
This is possible since version 1.0.8. Just set the correct values via the command line
./occ config:app:set --value="64 256 1024" previewgenerator squareSizes
./occ config:app:set --value="64 256 1024" previewgenerator widthSizes
./occ config:app:set --value="64 256 1024" previewgenerator heightSizes
This will only generate:
Note:
You need to increase the memory allowance of PHP, by default it is 128 MB. You do that by changing the memory_limit in the php.ini file.
If you use the docker container you need set the environment variable PHP_MEMORY_LIMIT
instead.
Add an empty file with the name .nomedia
in the folder you wish to skip. All files and subfolders of the folder containing .nomedia
will also be skipped.
WARNING: This is not supported but it has been confirmed to work by multiple users. Proceed at your own risk. Always keep backups around.
your-nextcloud-data-directory/appdata_*/preview
preview_max_x
and preview_max_y
in config.php
(e.g., to 512
), and change the previewgenerator
app parameters heightSizes
, squareSizes
and widthSizes
as per the README (or better yet, to a low value each, e.g. 512
, 256
and 512
respectively)occ files:scan-app-data
(this will reset generated previews in the database)occ preview:generate-all [user-id]
(this will run very fast if you did step 2)