aboutsummaryrefslogtreecommitdiff
path: root/transcoder
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-04-12 14:04:58 +0200
committermetamuffin <metamuffin@disroot.org>2024-04-12 14:05:14 +0200
commit1179447d0934e6205af2e37a1d0a9eed514b5523 (patch)
tree62613b970f33ef59a4932d5a0d2c8636499be182 /transcoder
parentf4615488b3bb25187003d457927c5ad3ea1d7900 (diff)
downloadjellything-1179447d0934e6205af2e37a1d0a9eed514b5523.tar
jellything-1179447d0934e6205af2e37a1d0a9eed514b5523.tar.bz2
jellything-1179447d0934e6205af2e37a1d0a9eed514b5523.tar.zst
better avif guessing
Diffstat (limited to 'transcoder')
-rw-r--r--transcoder/src/image.rs19
1 files 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();