{"id":13584656,"url":"https://github.com/nextcloud/previewgenerator","last_synced_at":"2025-04-07T21:10:04.922Z","repository":{"id":40268946,"uuid":"72203780","full_name":"nextcloud/previewgenerator","owner":"nextcloud","description":"Nextcloud app to do preview generation in the background.","archived":false,"fork":false,"pushed_at":"2024-10-28T02:43:33.000Z","size":499,"stargazers_count":456,"open_issues_count":84,"forks_count":57,"subscribers_count":18,"default_branch":"main","last_synced_at":"2024-10-29T15:51:06.784Z","etag":null,"topics":["nextcloud","previews"],"latest_commit_sha":null,"homepage":"https://apps.nextcloud.com/apps/previewgenerator","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nextcloud.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-28T12:01:18.000Z","updated_at":"2024-10-16T11:05:59.000Z","dependencies_parsed_at":"2023-11-13T10:26:05.049Z","dependency_job_id":"af6b305d-3dd5-450d-8454-90f1f81d5619","html_url":"https://github.com/nextcloud/previewgenerator","commit_stats":{"total_commits":230,"total_committers":30,"mean_commits":7.666666666666667,"dds":0.6391304347826087,"last_synced_commit":"78c2819e2fc490b9f9dae48ac92aa246cc110082"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextcloud%2Fpreviewgenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextcloud%2Fpreviewgenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextcloud%2Fpreviewgenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextcloud%2Fpreviewgenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nextcloud","download_url":"https://codeload.github.com/nextcloud/previewgenerator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730068,"owners_count":20986404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nextcloud","previews"],"created_at":"2024-08-01T15:04:25.434Z","updated_at":"2025-04-07T21:10:04.895Z","avatar_url":"https://github.com/nextcloud.png","language":"PHP","readme":"# Preview Generator\n\nNextcloud app that allows admins to pre-generate previews. The app listens to \nedit events and stores this information. Once a cron job is triggered it will\nstart preview generation. This means that you can better utilize your\nsystem by pre-generating previews when your system is normally idle and thus \nputting less load on your machine when the requests are actually served.\n\nThis app is primarily meant for small Nextcloud servers running on cheap\nhardware where on-demand generation of previews is not quick enough. The app\neffectively trades higher disk usage for quicker previews and this trade-off\nshould be considered carefully. The previous reasoning of resource exhaustion\ncaused by too many concurrent preview requests is not a concern anymore as\nthere is a [configurable limit](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#preview-concurrency-all)\nin modern versions of Nextcloud.\n\nThe app does not replace on demand preview generation so if a preview is \nrequested before it is pre-generated it will still be shown.\n\n## How to install\n\n* Install directly from within your Nextcloud from the [app store](https://apps.nextcloud.com/apps/previewgenerator)\n* Clone this repository into your Nextcloud app folder\n\n## How to use the app\n\n1. Install the app\n2. Enable the app\n3. Run `./occ preview:generate-all` once after installation.\n4. Add a (system) cron job for ` ./occ preview:pre-generate`\n  * I run it every 10 minutes\n\n## Known issues\n\n* The app does not work with encryption enabled\n\n## How does the app work\n\n1. Listen to events that a file has been written or modified and store it in the database\n2. On cron run request previews for the files that have been written or modified\n\nIf a preview already exists at step 2 then requesting it is really cheap. If not\nit will be generated. Depending on the sizes of the files and the hardware you\nare running on the time this takes can vary.\n\n## Commands\n\n#### `preview:generate-all [--path=PATH ...] [user_id ...]`\n\nLoop over all files and try to generate previews for them. If one or multiple user ids are supplied\nit will just loop over the files of those users. You can also limit the generation to one or more\npaths using `--path=\"/[username]/files/[folder path]\"`, e.g. `--path=\"/alice/files/Photos\"`. Note\nthat all given user_ids are ignored if at least one path is specified.\n\n#### `preview:pre-generate`\n\nDo the actual pre-generation. This means only for new or modified files (since the app was enabled\nor the last pre-generation was done).\n\nUse `\u003ccommand\u003e -vv` to get a more verbose output if you are interested to see which files are being\nprocessed.\n\n## Available configuration options\n\nThe value of each option can either be a list of sizes separated by **spaces** or an empty string.\nSetting an empty string will simply skip those kinds of previews.\nDeleting or not setting a config will use a built-in default list of values for those previews.\n\n* Preview sizes must be a power of 4! Other sizes are silently ignored.\n* The smallest possible size is 64.\n* The max size is determined by your `preview_max_x` and `preview_max_y` settings in `config.php`.\n\n#### `occ config:app:set --value=\"64 256\" previewgenerator squareSizes`\nCropped square previews which are mostly used in the list and tile views of the files app.\n\n#### `occ config:app:set --value=\"256 4096\" previewgenerator squareUncroppedSizes`\nWill retain the aspect ratio and try to maximize **either** width **or** height.\n\n#### `occ config:app:set --value=\"64 256 1024\" previewgenerator widthSizes`\nWill retain the aspect ratio and use the specified width. The height will be scaled according to\nthe aspect ratio.\n\n#### `occ config:app:set --value=\"64 256 1024\" previewgenerator heightSizes`\nWill retain the aspect ratio and use the specified height. The width will be scaled according to\nthe aspect ratio.\n\n\n## FAQ\n\n### Why can't I use webcron?\n\nPreview generation can be a very long running job. Thus we need a system that\ndoes not time out.\n\n### I get \"Command already running\"\n\nYes this happens when the `pre-generate` command crashes. No worries the lock\nwill be released after 30 minutes of inactivity from the app. So go grab a cookie.\n\n### What if I'm using Nextcloud All In One?\n\nFollow [these instructions](https://github.com/nextcloud/all-in-one/discussions/542)\n\n### I don't want to generate all the preview sizes\n\nThe following options are recommended if you only want to generate a minimum set of required\npreviews.\nThis should include all previews requested by the files, photos and activity apps.\n\n```\n./occ config:app:set --value=\"64 256\" previewgenerator squareSizes\n./occ config:app:set --value=\"256 4096\" previewgenerator squareUncroppedSizes\n./occ config:app:set --value=\"\" previewgenerator widthSizes\n./occ config:app:set --value=\"\" previewgenerator heightSizes\n```\n\nThis will only generate:\n* Cropped square previews of: 64x64 and 256x256\n* Aspect ratio previews with a max width **or** max height of: 256 and 4096\n\n### I get  \"PHP Fatal error:  Allowed memory size of X bytes exhausted\"\nYou 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.\n\nIf you use [the docker container](https://github.com/nextcloud/docker) you need set the environment variable `PHP_MEMORY_LIMIT` instead.\n\n### I want to skip a folder and everything in/under it\n\nAdd 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.\n\n### I want to reset/regenerate all previews\n\n**WARNING:** This is not supported but it has been confirmed to work by multiple users. Proceed at your own risk. Always keep backups around.\n\n1. Remove the folder `your-nextcloud-data-directory/appdata_*/preview`\n2. *Optional:* change parameters `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)\n3. Run `occ files:scan-app-data` (this will reset generated previews in the database)\n4. Run `occ preview:generate-all [user-id]` (this will run very fast if you did step 2) \n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextcloud%2Fpreviewgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextcloud%2Fpreviewgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextcloud%2Fpreviewgenerator/lists"}