nextcloud / nextcloud/previewgenerator

[Bug]: Max sized preview gets generated, regardless of specifications

Open
#518 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
520
Forks
55
PR merge metrics
No merged PRs in 30d

Description

⚠️ This issue respects the following points: ⚠️
Bug description

It seems that when a preview generation is triggered, e.g., using the preview generator app, regardless of the given specification, the generatePreviews method always generates the maxPreview with resolution using the max possible, according to the preview_max_x and preview_max_y parameters.

This is definitely undesirable, as it defeats the whole point of having small pre-generated previews, while having large on-demand previews, when needed. In fact, in the current state, the max preview is going to take the same space as the original picture in most cases, and thus, it does not make sense to pre-generate it.

The affected line of code is here.
In particular, the function getMaxPreview will generate the max preview, if it is not found, but this should not happen, if the specification parameter does not require this preview to be generated.

Steps to reproduce
  1. Trigger preview generation with the preview generator app specifying only, e.g., 64 256 as sizes
  2. Look for previews in the data/app_xxx/preview/ folder and see they are generated at max resolution, regardless of the 64 256 specification
Expected behavior

Only previews of the specified size are generated, while other previews of larger size (up to the max specified in the config) are only generated on-demand.

And before anyone tries to say this, no, reducing the value of the preview_max_x/y parameters is not a solution as this will also force the on-demand generation of previews to be capped at that value, which is also undesirable, as this will make fullscreen pictures in the Photo app to be rendered at a low resolution, while in this case, it is desirable to get a preview at the maximum resolution possible: either the one specified in the preview_max_x/y parameter, or if they are not set, the closest to the screen resolution.

Nextcloud Server version

30

Operating system

Other

PHP engine version

PHP 8.3

Web server

None

Database engine version

None

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report

No response

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/private/Preview/Generator.php around line 120, focusing on generatePreviews and its call to getMaxPreview. Reproduce the issue with the preview generator app using only 64 × 256 sizes, then verify that only requested sizes are generated while larger previews remain available for on-demand generation up to the configured maximum.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.