nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.19k stars 4.04k forks source link

[Bug]: HIF photos don't get preview generated #46408

Open ngocphamm opened 3 months ago

ngocphamm commented 3 months ago

⚠️ This issue respects the following points: ⚠️

Bug description

My camera produces photos in .HIF extension, and according to this, I think it's for the potential extended color profile.

The lesser-known variation, HEIX, provides differing features from HEIC. The primary difference is its support for color profiles that extend past 8-bit depth per color channel and chroma subsampling past 4:2:0 (4:2:2 or 4:4:4). Images saved in the HEIX variation use the .hif file extension.

However, uploading such photos to my test Nextcloud selfhosted instance result in the preview not being generated.

  1. Manually changing the extension to .heic will make it work.
  2. I also tried a simple code snippet similar to what I can find that might be responsible to generating preview for HEIC files here, and it looks like it still can properly return the mime as /image/x-heic.
  3. Using a normal .heic photo from my phone, that would upload and genrate preview just fine in Nextcloud, but if I change the extension to .hif, it fails. This makes me think this is the extension check issue, and probably not mime type check.

I tried to trace this myself browsing the code, but I'm not familiar with the structure of this project so I coudn't really find it after a couple hours.

Steps to reproduce

  1. Get any HEIC photo (with .heic extension)
  2. Upload the photo to Nextcloud. This should work, with preview being generated.
  3. Manually change the photo's extension to .hif/HIF
  4. Upload this new file to Nextcloud. This time it should fail.

Expected behavior

Nextcloud should be able to handle .hif/HIF files as it's basically still HEIC images, and it is able to handle it if the file's extension is manually changed to .heic.

Installation method

Community Docker image

Nextcloud Server version

29

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Nginx

Database engine version

SQlite

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

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

Configuration report

{
    "system": {
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "upgrade.disable-web": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.203.234:8088",
            "nextcloud-nginx",
            "my-domain"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "sqlite3",
        "version": "29.0.3.4",
        "overwrite.cli.url": "http:\/\/192.168.203.234:8088",
        "installed": true,
        "enabledPreviewProviders": [
            "OC\\Preview\\HEIC",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\Markdown",
            "OC\\Preview\\PNG",
            "OC\\Preview\\TXT"
        ],
        "loglevel": 2
    }
}

List of activated Apps

Enabled:
  - activity: 2.21.1
  - cloud_federation_api: 1.12.0
  - comments: 1.19.0
  - dashboard: 7.9.0
  - dav: 1.30.1
  - federatedfilesharing: 1.19.0
  - files: 2.1.0
  - files_downloadlimit: 2.0.0
  - files_pdfviewer: 2.10.0
  - files_reminders: 1.2.0
  - files_sharing: 1.21.0
  - files_trashbin: 1.19.0
  - files_versions: 1.22.0
  - firstrunwizard: 2.18.0
  - logreader: 2.14.0
  - lookup_server_connector: 1.17.0
  - nextcloud_announcements: 1.18.0
  - notifications: 2.17.0
  - oauth2: 1.17.0
  - onlyoffice: 9.3.0
  - photos: 2.5.0
  - privacy: 1.13.0
  - provisioning_api: 1.19.0
  - recommendations: 2.1.0
  - related_resources: 1.4.0
  - serverinfo: 1.19.0
  - settings: 1.12.0
  - systemtags: 1.19.0
  - text: 3.10.1
  - theming: 2.4.0
  - twofactor_backupcodes: 1.18.0
  - updatenotification: 1.19.1
  - user_status: 1.9.0
  - viewer: 2.3.0
  - workflowengine: 2.11.0
Disabled:
  - admin_audit: 1.19.0
  - bruteforcesettings: 2.9.0
  - camerarawpreviews: 0.8.5 (installed 0.8.5)
  - circles: 29.0.0-dev (installed 29.0.0-dev)
  - contactsinteraction: 1.10.0 (installed 1.10.0)
  - encryption: 2.17.0
  - federation: 1.19.0 (installed 1.19.0)
  - files_external: 1.21.0
  - password_policy: 1.19.0 (installed 1.19.0)
  - richdocuments: 8.4.3 (installed 8.4.3)
  - sharebymail: 1.19.0 (installed 1.19.0)
  - support: 1.12.0 (installed 1.12.0)
  - survey_client: 1.17.0 (installed 1.17.0)
  - suspicious_login: 7.0.0
  - twofactor_totp: 11.0.0-dev
  - user_ldap: 1.20.0
  - weather_status: 1.9.0 (installed 1.9.0)

Nextcloud Signing status

No response

Nextcloud Logs

I don't see log entries at the time this happens.

Additional info

No response

ngocphamm commented 8 hours ago

Anyone can point me to the module that is responsible to generate previews for photos? I think I can have a look, but I'm kinda lost with the codebase with all the abstraction layers.