From 1179447d0934e6205af2e37a1d0a9eed514b5523 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 12 Apr 2024 14:04:58 +0200 Subject: better avif guessing --- transcoder/src/image.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/transcoder/src/image.rs b/transcoder/src/image.rs index c9749fc..3589ab9 100644 --- a/transcoder/src/image.rs +++ b/transcoder/src/image.rs @@ -41,10 +41,23 @@ pub async fn transcode( file.seek(SeekFrom::Start(0)) .context("seeking back to start")?; // TODO: magic experimentally found and probably not working in all cases but fine as long as our avif enc uses that - magic - == [ - 0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x61, 0x76, 0x69, 0x66, + matches!( + magic, + [ + 0x00, + 0x00, + 0x00, + _, + b'f', + b't', + b'y', + b'p', + b'a', + b'v', + b'i', + b'f', ] + ) }; let original = if is_avif { let mut buf = Vec::new(); -- cgit v1.2.3-70-g09d2