pillow-avif-plugin 1.3.1__cp310-cp310-win_amd64.whl → 1.4.4__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pillow-avif-plugin might be problematic. Click here for more details.
- pillow_avif/AvifImagePlugin.py +37 -21
- pillow_avif/__init__.py +1 -1
- pillow_avif/_avif.cp310-win_amd64.pyd +0 -0
- {pillow_avif_plugin-1.3.1.dist-info → pillow_avif_plugin-1.4.4.dist-info}/METADATA +36 -35
- pillow_avif_plugin-1.4.4.dist-info/RECORD +9 -0
- {pillow_avif_plugin-1.3.1.dist-info → pillow_avif_plugin-1.4.4.dist-info}/WHEEL +1 -1
- pillow_avif_plugin-1.3.1.dist-info/RECORD +0 -9
- {pillow_avif_plugin-1.3.1.dist-info → pillow_avif_plugin-1.4.4.dist-info}/LICENSE +0 -0
- {pillow_avif_plugin-1.3.1.dist-info → pillow_avif_plugin-1.4.4.dist-info}/top_level.txt +0 -0
- {pillow_avif_plugin-1.3.1.dist-info → pillow_avif_plugin-1.4.4.dist-info}/zip-safe +0 -0
pillow_avif/AvifImagePlugin.py
CHANGED
|
@@ -3,7 +3,7 @@ from __future__ import division
|
|
|
3
3
|
from io import BytesIO
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
|
-
from PIL import Image, ImageFile
|
|
6
|
+
from PIL import ExifTags, Image, ImageFile
|
|
7
7
|
|
|
8
8
|
try:
|
|
9
9
|
from pillow_avif import _avif
|
|
@@ -16,6 +16,7 @@ except ImportError:
|
|
|
16
16
|
# to Image.open (see https://github.com/python-pillow/Pillow/issues/569)
|
|
17
17
|
DECODE_CODEC_CHOICE = "auto"
|
|
18
18
|
CHROMA_UPSAMPLING = "auto"
|
|
19
|
+
DEFAULT_MAX_THREADS = 0
|
|
19
20
|
|
|
20
21
|
_VALID_AVIF_MODES = {"RGB", "RGBA"}
|
|
21
22
|
|
|
@@ -51,15 +52,17 @@ def _accept(prefix):
|
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
class AvifImageFile(ImageFile.ImageFile):
|
|
54
|
-
|
|
55
55
|
format = "AVIF"
|
|
56
56
|
format_description = "AVIF image"
|
|
57
57
|
__loaded = -1
|
|
58
58
|
__frame = 0
|
|
59
59
|
|
|
60
|
+
def load_seek(self, pos):
|
|
61
|
+
pass
|
|
62
|
+
|
|
60
63
|
def _open(self):
|
|
61
64
|
self._decoder = _avif.AvifDecoder(
|
|
62
|
-
self.fp.read(), DECODE_CODEC_CHOICE, CHROMA_UPSAMPLING
|
|
65
|
+
self.fp.read(), DECODE_CODEC_CHOICE, CHROMA_UPSAMPLING, DEFAULT_MAX_THREADS
|
|
63
66
|
)
|
|
64
67
|
|
|
65
68
|
# Get info from decoder
|
|
@@ -67,7 +70,10 @@ class AvifImageFile(ImageFile.ImageFile):
|
|
|
67
70
|
self._size = width, height
|
|
68
71
|
self.n_frames = n_frames
|
|
69
72
|
self.is_animated = self.n_frames > 1
|
|
70
|
-
|
|
73
|
+
try:
|
|
74
|
+
self.mode = self.rawmode = mode
|
|
75
|
+
except AttributeError:
|
|
76
|
+
self._mode = self.rawmode = mode
|
|
71
77
|
self.tile = []
|
|
72
78
|
|
|
73
79
|
if icc:
|
|
@@ -124,27 +130,16 @@ def _save(im, fp, filename, save_all=False):
|
|
|
124
130
|
|
|
125
131
|
is_single_frame = total == 1
|
|
126
132
|
|
|
127
|
-
qmin = info.get("qmin")
|
|
128
|
-
qmax = info.get("qmax")
|
|
129
|
-
|
|
130
|
-
if
|
|
131
|
-
|
|
132
|
-
# to 63 (worst quality). If neither are explicitly specified, we use a 0-100
|
|
133
|
-
# quality scale (default 75) and calculate the qmin and qmax from that.
|
|
134
|
-
#
|
|
135
|
-
# - qmin is 0 for quality >= 64. Below that, qmin has an inverse linear
|
|
136
|
-
# relation to quality (i.e., quality 63 = qmin 1, quality 0 => qmin 63)
|
|
137
|
-
# - qmax is 0 for quality=100, then qmax increases linearly relative to
|
|
138
|
-
# quality decreasing, until it flattens out at quality=37.
|
|
139
|
-
quality = info.get("quality", 75)
|
|
140
|
-
if not isinstance(quality, int):
|
|
141
|
-
raise ValueError("Invalid quality setting")
|
|
142
|
-
qmin = max(0, min(64 - quality, 63))
|
|
143
|
-
qmax = max(0, min(100 - quality, 63))
|
|
133
|
+
qmin = info.get("qmin", -1)
|
|
134
|
+
qmax = info.get("qmax", -1)
|
|
135
|
+
quality = info.get("quality", 75)
|
|
136
|
+
if not isinstance(quality, int) or quality < 0 or quality > 100:
|
|
137
|
+
raise ValueError("Invalid quality setting")
|
|
144
138
|
|
|
145
139
|
duration = info.get("duration", 0)
|
|
146
140
|
subsampling = info.get("subsampling", "4:2:0")
|
|
147
141
|
speed = info.get("speed", 6)
|
|
142
|
+
max_threads = info.get("max_threads", DEFAULT_MAX_THREADS)
|
|
148
143
|
codec = info.get("codec", "auto")
|
|
149
144
|
range_ = info.get("range", "full")
|
|
150
145
|
tile_rows_log2 = info.get("tile_rows", 0)
|
|
@@ -156,6 +151,20 @@ def _save(im, fp, filename, save_all=False):
|
|
|
156
151
|
exif = info.get("exif", im.info.get("exif"))
|
|
157
152
|
if isinstance(exif, Image.Exif):
|
|
158
153
|
exif = exif.tobytes()
|
|
154
|
+
|
|
155
|
+
exif_orientation = 0
|
|
156
|
+
if exif:
|
|
157
|
+
exif_data = Image.Exif()
|
|
158
|
+
try:
|
|
159
|
+
exif_data.load(exif)
|
|
160
|
+
except SyntaxError:
|
|
161
|
+
pass
|
|
162
|
+
else:
|
|
163
|
+
orientation_tag = next(
|
|
164
|
+
k for k, v in ExifTags.TAGS.items() if v == "Orientation"
|
|
165
|
+
)
|
|
166
|
+
exif_orientation = exif_data.get(orientation_tag) or 0
|
|
167
|
+
|
|
159
168
|
xmp = info.get("xmp", im.info.get("xmp") or im.info.get("XML:com.adobe.xmp"))
|
|
160
169
|
|
|
161
170
|
if isinstance(xmp, text_type):
|
|
@@ -187,7 +196,9 @@ def _save(im, fp, filename, save_all=False):
|
|
|
187
196
|
subsampling,
|
|
188
197
|
qmin,
|
|
189
198
|
qmax,
|
|
199
|
+
quality,
|
|
190
200
|
speed,
|
|
201
|
+
max_threads,
|
|
191
202
|
codec,
|
|
192
203
|
range_,
|
|
193
204
|
tile_rows_log2,
|
|
@@ -196,6 +207,7 @@ def _save(im, fp, filename, save_all=False):
|
|
|
196
207
|
autotiling,
|
|
197
208
|
icc_profile or b"",
|
|
198
209
|
exif or b"",
|
|
210
|
+
exif_orientation,
|
|
199
211
|
xmp or b"",
|
|
200
212
|
advanced,
|
|
201
213
|
)
|
|
@@ -221,6 +233,10 @@ def _save(im, fp, filename, save_all=False):
|
|
|
221
233
|
"A" in ims.mode
|
|
222
234
|
or "a" in ims.mode
|
|
223
235
|
or (ims.mode == "P" and "A" in ims.im.getpalettemode())
|
|
236
|
+
or (
|
|
237
|
+
ims.mode == "P"
|
|
238
|
+
and ims.info.get("transparency", None) is not None
|
|
239
|
+
)
|
|
224
240
|
)
|
|
225
241
|
rawmode = "RGBA" if alpha else "RGB"
|
|
226
242
|
frame = ims.convert(rawmode)
|
pillow_avif/__init__.py
CHANGED
|
Binary file
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: pillow-avif-plugin
|
|
3
|
-
Version: 1.
|
|
4
|
-
Summary: A pillow plugin that adds avif support via libavif
|
|
5
|
-
Home-page: https://github.com/fdintino/pillow-avif-plugin/
|
|
6
|
-
Download-URL: https://github.com/fdintino/pillow-avif-plugin/releases
|
|
7
|
-
Author: Frankie Dintino
|
|
8
|
-
Author-email: fdintino@theatlantic.com
|
|
9
|
-
License: MIT License
|
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
-
Classifier: Environment :: Web Environment
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Operating System :: OS Independent
|
|
15
|
-
Classifier: Programming Language :: C
|
|
16
|
-
Classifier: Programming Language :: C++
|
|
17
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
18
|
-
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
-
Classifier: Programming Language :: Python ::
|
|
25
|
-
Classifier: Programming Language :: Python :: Implementation ::
|
|
26
|
-
Classifier:
|
|
27
|
-
Classifier: Topic :: Multimedia :: Graphics
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pillow-avif-plugin
|
|
3
|
+
Version: 1.4.4
|
|
4
|
+
Summary: A pillow plugin that adds avif support via libavif
|
|
5
|
+
Home-page: https://github.com/fdintino/pillow-avif-plugin/
|
|
6
|
+
Download-URL: https://github.com/fdintino/pillow-avif-plugin/releases
|
|
7
|
+
Author: Frankie Dintino
|
|
8
|
+
Author-email: fdintino@theatlantic.com
|
|
9
|
+
License: MIT License
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Environment :: Web Environment
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: C
|
|
16
|
+
Classifier: Programming Language :: C++
|
|
17
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
26
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
27
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
28
|
+
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
|
|
32
|
+
# pillow-avif-plugin
|
|
33
|
+
|
|
34
|
+
This is a plugin that adds support for AVIF files until official support has been added (see [this pull request](https://github.com/python-pillow/Pillow/pull/5201)).
|
|
35
|
+
|
|
36
|
+
To register this plugin with pillow you will need to add `import pillow_avif` somewhere in your application.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pillow_avif/AvifImagePlugin.py,sha256=frEKrbOSyxbVr4HCqjo0SgJxKLQ6lYvBO_8rg1PLsSo,8768
|
|
2
|
+
pillow_avif/__init__.py,sha256=7sAPSp1nzlfosFByw6n2fjTsQbYfQGPRrfsg72wIgxw,89
|
|
3
|
+
pillow_avif/_avif.cp310-win_amd64.pyd,sha256=17pmSu4qYQ65tlM1rlzEDzkYkcCGpJ-8jgKseocLkOE,27896832
|
|
4
|
+
pillow_avif_plugin-1.4.4.dist-info/LICENSE,sha256=tubzK3TFrT8GFgUPEKC-WmCziD1dGOFLCjDky3t9Lnc,1321
|
|
5
|
+
pillow_avif_plugin-1.4.4.dist-info/METADATA,sha256=hVrEQfrHp1oCYSBeRcAhLyS7Up2R0N0YuLjvKqgN0DA,1704
|
|
6
|
+
pillow_avif_plugin-1.4.4.dist-info/WHEEL,sha256=UZYoTfvcH9CL8oQkujTAI06MiAXK9kd09pSK3OpCC7k,101
|
|
7
|
+
pillow_avif_plugin-1.4.4.dist-info/top_level.txt,sha256=xrg4zRnqDyl_JEyEQh3oCcAU4BHneocD-DCFDzf4g9E,12
|
|
8
|
+
pillow_avif_plugin-1.4.4.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
9
|
+
pillow_avif_plugin-1.4.4.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
pillow_avif/AvifImagePlugin.py,sha256=yGgV3WWSKQb5XoPTuAkPGfRK8bIum2lHRksEmaZeuZs,8559
|
|
2
|
-
pillow_avif/__init__.py,sha256=2vOjmsU7AzmOPnimS7tfdkA62XwYC6_ZwqGDS5JOZTI,89
|
|
3
|
-
pillow_avif/_avif.cp310-win_amd64.pyd,sha256=efSrvItnnToDZ8XDE33OahlfL7VQWUJsdJOjuEHJF3U,22971392
|
|
4
|
-
pillow_avif_plugin-1.3.1.dist-info/LICENSE,sha256=tubzK3TFrT8GFgUPEKC-WmCziD1dGOFLCjDky3t9Lnc,1321
|
|
5
|
-
pillow_avif_plugin-1.3.1.dist-info/METADATA,sha256=rTTRsjx3PeNzanfCNxgqX0-GsXxmz87RKGnpjgxpJR0,1617
|
|
6
|
-
pillow_avif_plugin-1.3.1.dist-info/WHEEL,sha256=W26pYN7HLsBT1jrDSL9udgf_mdNKJmYmL23sIP-FcgM,102
|
|
7
|
-
pillow_avif_plugin-1.3.1.dist-info/top_level.txt,sha256=xrg4zRnqDyl_JEyEQh3oCcAU4BHneocD-DCFDzf4g9E,12
|
|
8
|
-
pillow_avif_plugin-1.3.1.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
9
|
-
pillow_avif_plugin-1.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|