From ad3a299fccebf08095572e3626c841cb8cba3de5 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev <mitya57@debian.org> Date: Sat, 9 Jul 2022 15:23:08 +0300 Subject: [PATCH] New upstream version 1.4.1 --- PKG-INFO | 4 +++- README.rst | 3 ++- imagesize.egg-info/PKG-INFO | 4 +++- imagesize.egg-info/SOURCES.txt | 3 ++- imagesize/__init__.py | 5 +++++ imagesize.py => imagesize/imagesize.py | 14 +++++++++++++- setup.py | 7 +++++-- 7 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 imagesize/__init__.py rename imagesize.py => imagesize/imagesize.py (95%) diff --git a/PKG-INFO b/PKG-INFO index ca67e11..8f8648f 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: imagesize -Version: 1.3.0 +Version: 1.4.1 Summary: Getting image size from png/jpeg/jpeg2000/gif file Home-page: https://github.com/shibukawa/imagesize_py Author: Yoshiki Shibukawa @@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Multimedia :: Graphics @@ -38,6 +39,7 @@ It parses image files' header and return image size. * TIFF * SVG * Netpbm +* WebP This is a pure Python library. diff --git a/README.rst b/README.rst index d1441b7..9704d22 100644 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ imagesize .. image:: https://travis-ci.org/shibukawa/imagesize_py.svg?branch=master :target: https://travis-ci.org/shibukawa/imagesize_py -This module analyzes JPEG/JPEG 2000/PNG/GIF/TIFF/SVG/Netpbm image headers and returns image size or DIP. +This module analyzes JPEG/JPEG 2000/PNG/GIF/TIFF/SVG/Netpbm/WebP image headers and returns image size or DIP. .. code:: python @@ -90,3 +90,4 @@ Thank you for feedback: * Hannes Römer (https://github.com/hroemer) * mikey (https://github.com/ffreemt) * Marco (https://github.com/marcoffee) +* ExtReMLapin (https://github.com/ExtReMLapin) diff --git a/imagesize.egg-info/PKG-INFO b/imagesize.egg-info/PKG-INFO index ca67e11..8f8648f 100644 --- a/imagesize.egg-info/PKG-INFO +++ b/imagesize.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: imagesize -Version: 1.3.0 +Version: 1.4.1 Summary: Getting image size from png/jpeg/jpeg2000/gif file Home-page: https://github.com/shibukawa/imagesize_py Author: Yoshiki Shibukawa @@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Multimedia :: Graphics @@ -38,6 +39,7 @@ It parses image files' header and return image size. * TIFF * SVG * Netpbm +* WebP This is a pure Python library. diff --git a/imagesize.egg-info/SOURCES.txt b/imagesize.egg-info/SOURCES.txt index 6a2b933..3c036d7 100644 --- a/imagesize.egg-info/SOURCES.txt +++ b/imagesize.egg-info/SOURCES.txt @@ -1,9 +1,10 @@ LICENSE.rst MANIFEST.in README.rst -imagesize.py setup.cfg setup.py +imagesize/__init__.py +imagesize/imagesize.py imagesize.egg-info/PKG-INFO imagesize.egg-info/SOURCES.txt imagesize.egg-info/dependency_links.txt diff --git a/imagesize/__init__.py b/imagesize/__init__.py new file mode 100644 index 0000000..8f001b6 --- /dev/null +++ b/imagesize/__init__.py @@ -0,0 +1,5 @@ +__all__ = ["get", "getDPI", "__version__"] + +__version__ = "1.4.1" + +from .imagesize import get, getDPI diff --git a/imagesize.py b/imagesize/imagesize.py similarity index 95% rename from imagesize.py rename to imagesize/imagesize.py index f700f14..e6ed07e 100644 --- a/imagesize.py +++ b/imagesize/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'): @@ -249,6 +249,18 @@ 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"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("Unsupported WebP file") finally: fhandle.close() diff --git a/setup.py b/setup.py index bf3ebd2..00db607 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,10 @@ #!/usr/bin/env python from setuptools import setup +from imagesize import __version__ setup(name='imagesize', - version='1.3.0', + version=__version__, description='Getting image size from png/jpeg/jpeg2000/gif file', long_description=''' It parses image files' header and return image size. @@ -15,6 +16,7 @@ It parses image files' header and return image size. * TIFF * SVG * Netpbm +* WebP This is a pure Python library. ''', @@ -22,7 +24,7 @@ This is a pure Python library. author_email='yoshiki@shibu.jp', url='https://github.com/shibukawa/imagesize_py', license="MIT", - py_modules=['imagesize'], + packages=['imagesize'], python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", classifiers=[ @@ -41,6 +43,7 @@ This is a pure Python library. 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Multimedia :: Graphics' -- GitLab