Compare commits

..

No commits in common. "7528d17e49c9d64f91cfdecd52bc44f012b501ef" and "d476c066ac7ccb02bdf0666d77c765db52cc7ae8" have entirely different histories.

6 changed files with 19 additions and 140 deletions

View File

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

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

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

BIN
imagesize-1.2.0.tar.gz Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,20 +1,24 @@
Name: python-imagesize Name: python-imagesize
Version: 1.3.0 Version: 1.2.0
Release: 6 Release: 1
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
Patch0002: 0002-fixed-support-for-VP8X.patch
Patch0003: 0003-Update-imagesize.py.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python3-setuptools BuildRequires: python2-setuptools python2-devel python2-pytest python3-setuptools
BuildRequires: python3-devel python3-pytest BuildRequires: python3-devel python3-pytest
%description %description
This module analyzes JPEG/JPEG 2000/PNG/GIF/TIFF image headers and returns image size. This module analyzes JPEG/JPEG 2000/PNG/GIF/TIFF image headers and returns image size.
%package -n python2-imagesize
Summary: This module analyzes image headers and returns image size.
%{?python_provide:%python_provide python2-imagesize}
%description -n python2-imagesize
This module analyzes JPEG/JPEG 2000/PNG/GIF/TIFF image headers and returns image size.
%package -n python3-imagesize %package -n python3-imagesize
Summary: This module analyzes image headers and returns image size. Summary: This module analyzes image headers and returns image size.
%{?python_provide:%python_provide python3-imagesize} %{?python_provide:%python_provide python3-imagesize}
@ -23,41 +27,27 @@ 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. This module analyzes JPEG/JPEG 2000/PNG/GIF/TIFF image headers and returns image size.
%prep %prep
%autosetup -n imagesize-%{version} -p1 %autosetup -n imagesize-%{version}
rm -rf imagesize.egg-info rm -rf imagesize.egg-info
%build %build
%py2_build
%py3_build %py3_build
%install %install
%py3_install %py3_install
%py2_install
%check %check
py.test-3 --ignore=./test/test_get_filelike.py py.test-2
py.test-3
%files -n python2-imagesize
%doc README.rst LICENSE.rst
%{python2_sitelib}/*
%files -n python3-imagesize %files -n python3-imagesize
%doc README.rst LICENSE.rst %doc README.rst LICENSE.rst
%{python3_sitelib}/* %{python3_sitelib}/*
%changelog %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
* Fri Jan 07 2022 renhongxun <renhongxun@huawei.com> - 1.3.0-2
- fix tests
* Mon Dec 27 2021 yanglongkang <yanglongkang@huawei.com> - 1.3.0-1
- update package to 1.3.0
* Thu Oct 29 2020 tianwei <tianwei@huawei.com> - 1.2.0-2
- delete python2 require
* Thu Jul 23 2020 dingyue <dingyue5@huawei.com> - 1.2.0-1 * Thu Jul 23 2020 dingyue <dingyue5@huawei.com> - 1.2.0-1
- Package update - Package update
* Mon Nov 25 2019 Ling Yang <lingyang2@huawei.com> - 1.0.0-4 * Mon Nov 25 2019 Ling Yang <lingyang2@huawei.com> - 1.0.0-4