Use preview provider for all sizes (instead of just the max)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
How to use GitHub
- Please use the 👍 reaction to show that you are interested into the same feature.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Is your feature request related to a problem? Please describe.
Since the integration of #24166, I'm experimenting the offloading of preview generation. My Nextcloud is installed on an Intel Atom, which is fine for serving file, but not manipulating images. I'm using Preview Generator along with an instance of Imaginary running on my fast desktop computer. But this is still painfully slow.
The fact is that generatePreviews uses the provider only in getMaxPreview. All others previews are still done by OC_Image, and this is the main bottleneck.
I've run preview:generate-all on a new folder with 9 JPEG images of 1280×960 (each ~550 KiB), and the cachgrind result (done with xdebug) is obvious:

For info I set:
'preview_max_memory' => 512,
'preview_max_x' => 2048,
'preview_max_y' => 2048,
Describe the solution you'd like
I'd like that generatePreviews use the thumbnail provider for all sizes, and not only the max preview.
Describe alternatives you've considered
I don't there is any.
Additional context
If I read the source code carefully, this introduce quite a big change. Since the provider selection is done in getMaxPreview and nowhere else, it must be moved in another function, and call the provider for every sizes. Potentially, the provider can be smarter and faster if it has all the size requests at once. So maybe the iteration can be done in the provider, with a default implementation to help "quick'n'dirty" provider to emerge.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/private/Preview/Generator.php, especially generatePreviews and getMaxPreview, then run preview:generate-all to reproduce the current behavior. Trace how the thumbnail provider is selected and how each requested size is produced. Done means the configured provider handles every preview size, not only the maximum, without breaking preview generation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100