feat(images): open AVIF - #50
Merged
Merged
Conversation
Every engine the viewer runs in decodes AVIF natively, so it belongs with the formats shown from the file itself rather than from a preview. Probed rather than assumed: a 64x64 AVIF decodes through both an img element and createImageBitmap in Chromium and in Firefox. No Nextcloud preview provider covers it, so listing it as preview-supported would have kept it unopenable everywhere. Closes nextcloud/viewer#407 Co-authored-by: JanisPlayer <JanisPlayer@users.noreply.github.com> Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #50 +/- ##
=======================================
Coverage 88.10% 88.11%
=======================================
Files 37 37
Lines 2624 2625 +1
Branches 558 558
=======================================
+ Hits 2312 2313 +1
Misses 305 305
Partials 7 7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Picks up nextcloud/viewer#1973 by @JanisPlayer, open since September 2023 and closed this morning with the repo. The question that held it up there was whether browser support was good enough; it is, and I measured it rather than reading a table.
A 64x64 AVIF, fed to both paths the viewer and the editor use:
<img>createImageBitmapSo it goes in
browserSupportedMimes, the list of formats shown from the file itself. That matters, because the other list would have made it worse rather than better:previewSupportedMimesis filtered against the server's enabled providers, and nothing in Nextcloud previews AVIF.HEIC.phpmentions avif at line 107, but that is a sanity check on what ImageMagick reports for a file claiming to be HEIC; itsgetMimeType()is/image\/(x-)?hei(f|c)/.Imaginary::supportedMimeTypes()does not list it either. Listed as preview-supported, AVIF would have been filtered straight back out on every server.Closes nextcloud/viewer#407.
The catch, which is not in this repo
An
.aviffile may never reach the viewer asimage/avifin the first place.resources/config/mimetypemapping.dist.jsonin server has noavifentry, andDetection::detectPath()returnsapplication/octet-streamfor an extension it does not know:detect()then falls back to content sniffing, so whether it is labelled correctly depends on the server's libmagic and on which code path stored the file. A one-line addition to the mapping would settle it. I have not opened that PR; say the word and I will.I have also not tested this against a live server, only against the playground, so that is the bit worth checking when you try it.
On jp2, the other half of #2587
Not included here, because by the same rule it qualifies for neither list.
No engine decodes it: the same probe on a JPEG 2000 file fails through both
<img>andcreateImageBitmap, in Chromium and in Firefox. And nothing previews it either.jp2appears in server only inmimetypemapping.dist.jsonandRepairMimeTypes.php; there is no provider, in core or in Imaginary, whose mime regex matches it.So an
image/jp2entry inpreviewSupportedMimeswould be filtered out on every stock server and show nothing. It is harmless, since the filter is self-gating, and it would light up on its own the day a provider exists, but today it is an entry that does nothing. I left it out rather than add dead configuration. Happy to add it if you would rather have it waiting.👾 This pull request was assisted by Claude Code, commits carry an
Assisted-bytrailer.