Repository navigation
fix(utils): detect AVIF and HEIC bytes as images - #300
Open
Manishram-ai wants to merge 1 commit into
Open
Manishram-ai wants to merge 1 commit into
Manishram-ai wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Follow-up to #257, which fixed this on the backend. AVIF and HEIC use the same
ftypcontainer as M4A, butdetectImageMimeTypedoesn't recognize them, sodetectAudioMimeTypereportsaudio/mp4and the viewer'svalueKindshows an audio player for these images. Base64 strings hit the same problem throughdetectBase64MimeType.This reads the major and compatible
ftypbrands indetectImageMimeType, with the same brand lists the backend's_detect_mime_typeuses. MP4 and M4A brands still fall through to audio.HEIC will only display where the browser can decode it. WebKit displayed my HEIC test files, and Chromium showed a broken image in place of the audio player.
Testing:
packages/utils/test/media.test.jsandpackages/viewer/test/renderer_utils.test.tsfail on main and pass with the fix. All 128 utils tests and 145 viewer tests pass.sipsandheif-enccome back as images as raw bytes,{bytes, path}objects and base64 strings. M4A, MP4 and MOV files from ffmpeg still come back as audio.tsc --buildand Prettier are clean.