python-imagesize/0001-added-support-for-webp-files.patch
2024-05-27 16:48:16 +08:00

29 lines
829 B
Diff

From b214d05c3899816d7f1f908145461453a6719ad2 Mon Sep 17 00:00:00 2001
From: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com>
Date: Fri, 29 Apr 2022 16:56:31 +0200
Subject: [PATCH] added support for webp files
---
imagesize.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/imagesize.py b/imagesize.py
index f700f14..9e1960a 100644
--- a/imagesize.py
+++ b/imagesize.py
@@ -249,6 +249,11 @@ def get(filepath):
fhandle.seek(-1, os.SEEK_CUR)
width, height = sizes
+ elif head.startswith(b"RIFF") and head[8:12] == b"WEBP":
+ # enter VP8 chunk
+ fhandle.seek(26)
+ width = struct.unpack("<H", fhandle.read(2))[0]
+ height = struct.unpack("<H", fhandle.read(2))[0]
finally:
fhandle.close()
--
2.39.0.windows.2