Sync release from 22.03-SP2

This commit is contained in:
wk333 2024-05-27 17:14:39 +08:00
parent ae055ff22b
commit 7df54ef9ba
3 changed files with 94 additions and 3 deletions

View File

@ -0,0 +1,45 @@
From 013a0dd3d3be5d47befd1bddfc8f35bac77835c5 Mon Sep 17 00:00:00 2001
From: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com>
Date: Tue, 3 May 2022 17:01:06 +0200
Subject: [PATCH] fixed support for VP8X
---
imagesize.py | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/imagesize.py b/imagesize.py
index 9e1960a..f4edd1d 100644
--- a/imagesize.py
+++ b/imagesize.py
@@ -96,7 +96,7 @@ def get(filepath):
fhandle = open(filepath, 'rb')
try:
- head = fhandle.read(24)
+ head = fhandle.read(31)
size = len(head)
# handle GIFs
if size >= 10 and head[:6] in (b'GIF87a', b'GIF89a'):
@@ -250,10 +250,15 @@ 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]
+ if head[12:16] == b"VP8L":
+ raise ValueError("Invalid WEBP file: Not a WebP file.")
+ elif head[12:16] == b"VP8 ":
+ width, height = struct.unpack("<HH", head[26:30])
+ elif head[12:16] == b"VP8X":
+ width = struct.unpack("<I", head[24:27] + b"\0")[0]
+ height = struct.unpack("<I", head[27:30] + b"\0")[0]
+ else:
+ raise ValueError("Invalid WEBP file: Not a WebP file.")
finally:
fhandle.close()
--
2.39.0.windows.2

View File

@ -0,0 +1,38 @@
From e7c81aa290e6832754dc8eaa911d831a381135c7 Mon Sep 17 00:00:00 2001
From: ExtReMLapin <3909752+ExtReMLapin@users.noreply.github.com>
Date: Tue, 3 May 2022 17:20:07 +0200
Subject: [PATCH] Update imagesize.py
---
imagesize.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/imagesize.py b/imagesize.py
index f4edd1d..e6ed07e 100644
--- a/imagesize.py
+++ b/imagesize.py
@@ -250,15 +250,17 @@ def get(filepath):
fhandle.seek(-1, os.SEEK_CUR)
width, height = sizes
elif head.startswith(b"RIFF") and head[8:12] == b"WEBP":
- if head[12:16] == b"VP8L":
- raise ValueError("Invalid WEBP file: Not a WebP file.")
- elif head[12:16] == b"VP8 ":
+ if head[12:16] == b"VP8 ":
width, height = struct.unpack("<HH", head[26:30])
elif head[12:16] == b"VP8X":
width = struct.unpack("<I", head[24:27] + b"\0")[0]
height = struct.unpack("<I", head[27:30] + b"\0")[0]
+ elif head[12:16] == b"VP8L":
+ b = head[21:25]
+ width = (((b[1] & 63) << 8) | b[0]) + 1
+ height = (((b[3] & 15) << 10) | (b[2] << 2) | ((b[1] & 192) >> 6)) + 1
else:
- raise ValueError("Invalid WEBP file: Not a WebP file.")
+ raise ValueError("Unsupported WebP file")
finally:
fhandle.close()
--
2.39.0.windows.2

View File

@ -1,11 +1,13 @@
Name: python-imagesize Name: python-imagesize
Version: 1.3.0 Version: 1.3.0
Release: 4 Release: 6
Summary: This module analyzes image headers and returns image size. Summary: This module analyzes image headers and returns image size.
License: MIT License: MIT
URL: https://github.com/shibukawa/imagesize_py URL: https://github.com/shibukawa/imagesize_py
Source0: https://files.pythonhosted.org/packages/source/i/imagesize/imagesize-%{version}.tar.gz Source0: https://files.pythonhosted.org/packages/source/i/imagesize/imagesize-%{version}.tar.gz
patch0001: 0001-added-support-for-webp-files.patch Patch0001: 0001-added-support-for-webp-files.patch
Patch0002: 0002-fixed-support-for-VP8X.patch
Patch0003: 0003-Update-imagesize.py.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python3-setuptools BuildRequires: python3-setuptools
BuildRequires: python3-devel python3-pytest BuildRequires: python3-devel python3-pytest
@ -35,7 +37,13 @@ py.test-3 --ignore=./test/test_get_filelike.py
%{python3_sitelib}/* %{python3_sitelib}/*
%changelog %changelog
* Tue Nov 28 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 1.3.0-4 * Thu Dec 28 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 1.3.0-6
- Update imagesize.py
* Fri Dec 22 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 1.3.0-5
- fixed support for VP8X
* Thu Oct 19 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 1.3.0-4
- added support for webp files - added support for webp files
* Tue Oct 25 2022 zhangruifang <zhangruifang1@h-partners.com> - 1.3.0-3 * Tue Oct 25 2022 zhangruifang <zhangruifang1@h-partners.com> - 1.3.0-3