pillow-avif-plugin 1.2.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 +48 -29
- pillow_avif/__init__.py +2 -2
- pillow_avif/_avif.cp310-win_amd64.pyd +0 -0
- {pillow_avif_plugin-1.2.1.dist-info → pillow_avif_plugin-1.4.4.dist-info}/METADATA +36 -38
- pillow_avif_plugin-1.4.4.dist-info/RECORD +9 -0
- {pillow_avif_plugin-1.2.1.dist-info → pillow_avif_plugin-1.4.4.dist-info}/WHEEL +1 -1
- pillow_avif_plugin-1.2.1.dist-info/RECORD +0 -9
- {pillow_avif_plugin-1.2.1.dist-info → pillow_avif_plugin-1.4.4.dist-info}/LICENSE +0 -0
- {pillow_avif_plugin-1.2.1.dist-info → pillow_avif_plugin-1.4.4.dist-info}/top_level.txt +0 -0
- {pillow_avif_plugin-1.2.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,41 +130,45 @@ 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 90) 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", 90)
|
|
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
|
-
speed = info.get("speed",
|
|
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)
|
|
151
|
-
tile_cols_log2 = info.get("
|
|
146
|
+
tile_cols_log2 = info.get("tile_cols", 0)
|
|
152
147
|
alpha_premultiplied = bool(info.get("alpha_premultiplied", False))
|
|
148
|
+
autotiling = bool(info.get("autotiling", tile_rows_log2 == tile_cols_log2 == 0))
|
|
153
149
|
|
|
154
150
|
icc_profile = info.get("icc_profile", im.info.get("icc_profile"))
|
|
155
151
|
exif = info.get("exif", im.info.get("exif"))
|
|
156
152
|
if isinstance(exif, Image.Exif):
|
|
157
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
|
+
|
|
158
168
|
xmp = info.get("xmp", im.info.get("xmp") or im.info.get("XML:com.adobe.xmp"))
|
|
159
169
|
|
|
160
170
|
if isinstance(xmp, text_type):
|
|
161
|
-
xmp = xmp.encode(
|
|
171
|
+
xmp = xmp.encode("utf-8")
|
|
162
172
|
|
|
163
173
|
advanced = info.get("advanced")
|
|
164
174
|
if isinstance(advanced, dict):
|
|
@@ -173,10 +183,11 @@ def _save(im, fp, filename, save_all=False):
|
|
|
173
183
|
if invalid:
|
|
174
184
|
raise ValueError(
|
|
175
185
|
"advanced codec options must be a dict of key-value string "
|
|
176
|
-
"pairs or a series of key-value two-tuples"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
for k, v in advanced]
|
|
186
|
+
"pairs or a series of key-value two-tuples"
|
|
187
|
+
)
|
|
188
|
+
advanced = tuple(
|
|
189
|
+
[(str(k).encode("utf-8"), str(v).encode("utf-8")) for k, v in advanced]
|
|
190
|
+
)
|
|
180
191
|
|
|
181
192
|
# Setup the AVIF encoder
|
|
182
193
|
enc = _avif.AvifEncoder(
|
|
@@ -185,16 +196,20 @@ def _save(im, fp, filename, save_all=False):
|
|
|
185
196
|
subsampling,
|
|
186
197
|
qmin,
|
|
187
198
|
qmax,
|
|
199
|
+
quality,
|
|
188
200
|
speed,
|
|
201
|
+
max_threads,
|
|
189
202
|
codec,
|
|
190
203
|
range_,
|
|
191
204
|
tile_rows_log2,
|
|
192
205
|
tile_cols_log2,
|
|
193
206
|
alpha_premultiplied,
|
|
207
|
+
autotiling,
|
|
194
208
|
icc_profile or b"",
|
|
195
209
|
exif or b"",
|
|
210
|
+
exif_orientation,
|
|
196
211
|
xmp or b"",
|
|
197
|
-
advanced
|
|
212
|
+
advanced,
|
|
198
213
|
)
|
|
199
214
|
|
|
200
215
|
# Add each frame
|
|
@@ -218,6 +233,10 @@ def _save(im, fp, filename, save_all=False):
|
|
|
218
233
|
"A" in ims.mode
|
|
219
234
|
or "a" in ims.mode
|
|
220
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
|
+
)
|
|
221
240
|
)
|
|
222
241
|
rawmode = "RGBA" if alpha else "RGB"
|
|
223
242
|
frame = ims.convert(rawmode)
|
pillow_avif/__init__.py
CHANGED
|
Binary file
|
|
@@ -1,38 +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
|
-
|
|
7
|
-
Author
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Classifier:
|
|
12
|
-
Classifier:
|
|
13
|
-
Classifier:
|
|
14
|
-
Classifier:
|
|
15
|
-
Classifier:
|
|
16
|
-
Classifier: Programming Language :: C
|
|
17
|
-
Classifier: Programming Language ::
|
|
18
|
-
Classifier: Programming Language :: Python ::
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.
|
|
24
|
-
Classifier: Programming Language :: Python :: 3.
|
|
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.
|
|
37
|
-
|
|
38
|
-
|
|
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=FEpA1ktnlRFsRmwI8-rCzq15tZozMymj0E4FWE0P9vA,8440
|
|
2
|
-
pillow_avif/__init__.py,sha256=9naq-agRCo3wFdZattLuZuC9yg_wX6eO4bb3ry3CGUo,89
|
|
3
|
-
pillow_avif/_avif.cp310-win_amd64.pyd,sha256=pL8x5cUwg0HNJBDhiE3KSJ8Wj48ggacKUlYct7TLkCI,17286656
|
|
4
|
-
pillow_avif_plugin-1.2.1.dist-info/LICENSE,sha256=tubzK3TFrT8GFgUPEKC-WmCziD1dGOFLCjDky3t9Lnc,1321
|
|
5
|
-
pillow_avif_plugin-1.2.1.dist-info/METADATA,sha256=_y94PFO1BjNmlJ6ivnT6bzzWYdYIcryOxQ9GM0YK7mQ,1636
|
|
6
|
-
pillow_avif_plugin-1.2.1.dist-info/WHEEL,sha256=C6CHup2HLC2Rld8AL5u9w89MYULjdaP5k0k7SG83CcI,102
|
|
7
|
-
pillow_avif_plugin-1.2.1.dist-info/top_level.txt,sha256=xrg4zRnqDyl_JEyEQh3oCcAU4BHneocD-DCFDzf4g9E,12
|
|
8
|
-
pillow_avif_plugin-1.2.1.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
9
|
-
pillow_avif_plugin-1.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|