!48 Sync release from 22.03-SP2

From: @wk333 
Reviewed-by: @lyn1001 
Signed-off-by: @lyn1001
This commit is contained in:
openeuler-ci-bot 2024-05-28 01:09:13 +00:00 committed by Gitee
commit 7528d17e49
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 125 additions and 2 deletions

View File

@ -0,0 +1,28 @@
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

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,10 +1,13 @@
Name: python-imagesize
Version: 1.3.0
Release: 3
Release: 6
Summary: This module analyzes image headers and returns image size.
License: MIT
URL: https://github.com/shibukawa/imagesize_py
Source0: https://files.pythonhosted.org/packages/source/i/imagesize/imagesize-%{version}.tar.gz
Patch0001: 0001-added-support-for-webp-files.patch
Patch0002: 0002-fixed-support-for-VP8X.patch
Patch0003: 0003-Update-imagesize.py.patch
BuildArch: noarch
BuildRequires: python3-setuptools
BuildRequires: python3-devel python3-pytest
@ -20,7 +23,7 @@ Summary: This module analyzes image headers and returns image size.
This module analyzes JPEG/JPEG 2000/PNG/GIF/TIFF image headers and returns image size.
%prep
%autosetup -n imagesize-%{version}
%autosetup -n imagesize-%{version} -p1
rm -rf imagesize.egg-info
%build
%py3_build
@ -34,6 +37,15 @@ py.test-3 --ignore=./test/test_get_filelike.py
%{python3_sitelib}/*
%changelog
* 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
* Tue Oct 25 2022 zhangruifang <zhangruifang1@h-partners.com> - 1.3.0-3
- Rebuild for next release