Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Preview generation for square image sizes between 257 and 512 are rounded up to 1024 #34244

Closed
5 of 9 tasks
invario opened this issue Sep 25, 2022 · 11 comments
Closed
5 of 9 tasks
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug

Comments

@invario
Copy link

invario commented Sep 25, 2022

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

The file listing one (via web interface) for example, uses a base thumbnail size of 250x250 and is then multiplied by the device's pixel ratio. The server translates it to a the nearest higher power of 2 value. So 250x250 becomes 256x256. This functions correctly, but the moment it goes above 256x256 (257x257, 258x258) the image generated becomes 1024x1024.

https://MYSERVER/core/preview?fileId=1703032&c=7b93d6eab1427002553cfb81c329adb0&x=257&y=257&forceIcon=0&a=0

This strikes me as incorrect because 512x512 is a power of 2 and should be the correct one utilized.

Steps to reproduce

  1. Upload images of various sizes to NextCloud
  2. View File listing of images.
  3. Inspect HTML and compare the requested X/Y values to actual image returned and note returned image is incorrect.

Expected behavior

Requested square images of sizes 257x257 through 512x512 should have a 512x512 image returned instead of 1024x1024.

Installation method

Other Community project

Operating system

Other

PHP engine version

PHP 7.4

Web server

Nginx

Database engine version

MySQL

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

Updated from a minor version (ex. 22.2.3 to 22.2.4)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "apps_paths": [
            {
                "path": "\/usr\/local\/www\/nextcloud\/apps",
                "url": "\/apps",
                "writable": true
            }
        ],
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "loglevel": 0,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0
        },
        "filelocking.enabled": true,
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "192.168.0.4",
            "MYSERVERADDRESS.COM"
        ],
        "enable_previews": true,
        "default_phone_region": "US",
        "enabledPreviewProviders": [
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\HEIC",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\MP3",
            "OC\\Preview\\MP4",
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\Movie"
        ],
        "preview_max_x": "1920",
        "preview_max_y": "1920",
        "jpeg_quality": "60",
        "updater.release.channel": "stable",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "24.0.5.1",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "maintenance": false,
        "theme": "",
        "trashbin_retention_obligation": "30,31"
    }
}

List of activated Apps

Enabled:
  - activity: 2.16.0
  - cloud_federation_api: 1.7.0
  - dav: 1.22.0
  - duplicatefinder: 0.0.15
  - federatedfilesharing: 1.14.0
  - files: 1.19.0
  - files_external: 1.16.1
  - files_pdfviewer: 2.5.0
  - files_sharing: 1.16.2
  - files_trashbin: 1.14.0
  - files_videoplayer: 1.13.0
  - firstrunwizard: 2.13.0
  - logreader: 2.9.0
  - lookup_server_connector: 1.12.0
  - metadata: 0.16.0
  - notifications: 2.12.1
  - oauth2: 1.12.0
  - password_policy: 1.14.0
  - photos: 1.6.0
  - previewgenerator: 5.0.0
  - privacy: 1.8.0
  - provisioning_api: 1.14.0
  - recommendations: 1.3.0
  - serverinfo: 1.14.0
  - settings: 1.6.0
  - survey_client: 1.12.0
  - theming: 1.15.0
  - twofactor_backupcodes: 1.13.0
  - twofactor_totp: 6.4.0
  - updatenotification: 1.14.0
  - video_converter: 1.0.5
  - viewer: 1.8.0
  - workflowengine: 2.6.0
Disabled:
  - accessibility: 1.6.0
  - admin_audit
  - circles: 22.1.1
  - comments: 1.10.0
  - contactsinteraction: 1.1.0
  - dashboard: 7.0.0
  - encryption
  - federation: 1.10.1
  - files_rightclick: 1.3.0
  - files_versions: 1.13.0
  - nextcloud_announcements: 1.9.0
  - sharebymail: 1.10.0
  - support: 1.3.0
  - systemtags: 1.10.0
  - text: 3.1.0
  - user_ldap
  - user_status: 1.0.1
  - weather_status: 1.0.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

No response

Additional info

No response

@invario invario added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Sep 25, 2022
@invario invario changed the title [Bug]: Preview generation for square images sizes between 256 and 512 are rounded up to 1024 [Bug]: Preview generation for square image sizes between 257 and 512 are rounded up to 1024 Sep 25, 2022
@invario
Copy link
Author

invario commented Sep 25, 2022

#13709

So apparently 512x512 is not supposed to be generated, crazy. This is a lot of wasted space and bandwidth to use a 1024x1024 image for thumbnails.

@invario invario closed this as completed Sep 25, 2022
@invario invario reopened this Sep 25, 2022
@invario
Copy link
Author

invario commented Sep 25, 2022

Reopened due to this actually not being resolved but simply as known.

I only have about 5 users actively using my NC setup to store photos so I can't even imagine someone in a much larger environment. I personally have over 300GB of photos/videos.

To reiterate what was in the above referenced posting, my browser (which is on a Windows PC at 3840x2160 resolution, 200% scale, and browser zoom of 100%, requests 500x500, which is overkill as is. The server generates a 1024x1024 image as a result.

-rw-r--r--  1 www  www   98377 Sep 24 20:53 1024-1024-crop.jpg
-rw-r--r--  1 www  www    9070 Sep 24 20:53 256-256-crop.jpg
-rw-r--r--  1 www  www  127708 Sep 24 17:11 1024-1024-crop.jpg
-rw-r--r--  1 www  www   11922 Sep 24 17:11 256-256-crop.jpg
-rw-r--r--  1 www  www   89066 Sep 24 16:56 1024-1024-crop.jpg
-rw-r--r--  1 www  www   12116 Sep 24 16:56 256-256-crop.jpg
-rw-r--r--  1 www  www   61608 Sep 24 21:49 1024-1024-crop.jpg
-rw-r--r--  1 www  www    8559 Sep 24 21:49 256-256-crop.jpg
-rw-r--r--  1 www  www  127708 Sep 24 17:11 1024-1024-crop.jpg
-rw-r--r--  1 www  www   11922 Sep 24 17:11 256-256-crop.jpg

A quick look at the thumbnails shows about a 6-10X size increase for 1024x1024 thumbs versus 256x256. This translates into a lot more bandwidth and a lot more storage space
The file listing for me uses 50x50 within the CSS and Grid view uses 160x160.

So this begs the question of why it's necessary to generate 1024x1024 for thumbnail images? I'm genuinely interested in knowing who has a display setup that would actually benefit from that large of a thumbnail image.

@solracsf
Copy link
Member

Please note that AFAIK images are not only used as (small) thumbnails, but also for when you click on the image to open it, like in Photos app, or even on Files apps. This can help too:

https://github.com/nextcloud/server/blob/master/config/config.sample.php#L1115-L1129

@invario
Copy link
Author

invario commented Sep 26, 2022

Please note that AFAIK images are not only used as (small) thumbnails, but also for when you click on the image to open it, like in Photos app, or even on Files apps. This can help too:

https://github.com/nextcloud/server/blob/master/config/config.sample.php#L1115-L1129

Hi, thank you. Yes, I know, but the image generated for when you click on the image to view it is a different image request at a different size too. Mine is capped at 1920 for X and Y already via the config.php

@keesfluitman
Copy link

I experienced the same, trying to only pregenerate the thumbnails, expecting the files app to just need 64x64, it actually requested much larger previews. Im not even close to generating all preview files and my preview folder is already 15GB. Plus the bandwith...

@szaimen
Copy link
Contributor

szaimen commented Jan 23, 2023

Hi, please update to 24.0.9 or better 25.0.3 and report back if it fixes the issue. Thank you!

My goal is to add a label like e.g. 25-feedback to this ticket of an up-to-date major Nextcloud version where the bug could be reproduced. However this is not going to work without your help. So thanks for all your effort!

If you don't manage to reproduce the issue in time and the issue gets closed but you can reproduce the issue afterwards, feel free to create a new bug report with up-to-date information by following this link: https://github.com/nextcloud/server/issues/new?assignees=&labels=bug%2C0.+Needs+triage&template=BUG_REPORT.yml&title=%5BBug%5D%3A+

@invario
Copy link
Author

invario commented Feb 10, 2023

Hi, just saw this, sorry, will check tonight and get updated info!

@invario
Copy link
Author

invario commented Feb 27, 2023

So unfortunately the bug still exists in NC 25.0.4.

This is the URL being tested:
https://server_address/core/preview?fileId=2382467&c=22f20fbafb9a4f3ec75499f3cc99c338&x=400&y=400&forceIcon=0&a=1

Which results in an image size of 1024x768 being generated.

@driscollw
Copy link

So unfortunately the bug still exists in NC 25.0.4.

This is the URL being tested: https://server_address/core/preview?fileId=2382467&c=22f20fbafb9a4f3ec75499f3cc99c338&x=400&y=400&forceIcon=0&a=1

Which results in an image size of 1024x768 being generated.

I've been fighting this for a while on different versions over the years. At this point I'm just trying to find a way to generate the grid resolutions ahead of time. Not a fan of the size for mobile, but I can deal with it. Thinking if I set the 2048 to 1024 then the server would have the correct 1024 needed for the grid view??

currently using
previewgenerator squareSizes --value="32 256"
previewgenerator widthSizes --value="256 384"
previewgenerator heightSizes --value="256"
preview_max_x --value 2048
preview_max_y --value 2048

@invario
Copy link
Author

invario commented Apr 17, 2023

So as of NC 26, this is still occurring. That is, a request for square size x=257 y=257 still generates 1024x1024 instead of the higher and nearest power of 2 of 512x512.

@invario
Copy link
Author

invario commented Apr 19, 2023

Consider this closed. Apparently in NC versions 25 and up, previews are only generated for sizes 64, 256, 1024, and 4096. I'm not even sure if you can generate anything over 4,096 anymore or if that is a hard limit... But there you go, powers of 4, not powers of 2.

@invario invario closed this as completed Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug
Projects
None yet
Development

No branches or pull requests

5 participants