Skip to content

AVIF image orientation#2750

Merged
197g merged 13 commits intoimage-rs:mainfrom
Shnatsel:avif-image-orientation
Jan 30, 2026
Merged

AVIF image orientation#2750
197g merged 13 commits intoimage-rs:mainfrom
Shnatsel:avif-image-orientation

Conversation

@Shnatsel
Copy link
Copy Markdown
Member

@Shnatsel Shnatsel commented Jan 29, 2026

Instead of something sensible like Exif rotation encoding, they came up with a custom scheme to encode the same thing more verbosely.

Tested on sample images with https://github.com/link-u/avif-sample-images - all pass, but the tests there are non-exhaustive.

Curiously Chromium displays them correctly while Firefox seems to outright reject the sample images with orientation metadata.

Unfortunately this requires some unsafe due to mp4parse only exposing pointer API for mirroring, and I don't trust them to make a timely release since the last release was over 2 years ago.

@Shnatsel Shnatsel force-pushed the avif-image-orientation branch from e88344d to 9a5139f Compare January 29, 2026 09:46
@Shnatsel Shnatsel marked this pull request as ready for review January 29, 2026 10:10
@Shnatsel
Copy link
Copy Markdown
Member Author

This is now ready to go. Please take another look - I had to use some unsafe due to mp4parse only exposing pointer API for mirroring, and I don't trust them to make a timely release with an upstream change since the last release was over 2 years ago.

Copy link
Copy Markdown
Member

@197g 197g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-motivated unsafe is alright with me and that's a possibility here. I tend to agree with the reasoning even though mp4parse does not spell out that it will return a valid, read-only pointer that isn't possibly written concurrently.

Might be worth opening a tracking issue about the outdated mp4parse releases. Are they looking for alternative maintainers? Or we evaluate newer crates (https://github.com/rerun-io/re_mp4) that also have less dependencies. But that does not need immediate attention.

@Shnatsel
Copy link
Copy Markdown
Member Author

mp4parse activity is still happening in git, but releases haven't been published to crates.io in quite some time. I'm not sure what the maintenance status is.

I've opened an upstream PR for a safe wrapper today, we'll see how it goes: mozilla/mp4parse-rust#440

@197g 197g force-pushed the avif-image-orientation branch from aca2b1d to 5e7bf5a Compare January 30, 2026 01:00
@fintelia
Copy link
Copy Markdown
Contributor

The last published releases of mp4parse were actually at our request. My understanding is that the crate is used by Firefox which gets it from GitHub rather than crates.io

@197g 197g merged commit ea8eead into image-rs:main Jan 30, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants