pillow-avif-plugin 1.2.2__cp37-cp37m-macosx_10_10_x86_64.whl → 1.4.4__cp37-cp37m-macosx_10_10_x86_64.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.

@@ -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
- self.mode = self.rawmode = mode
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 qmin is None and qmax is None:
131
- # The min and max quantizer settings in libavif range from 0 (best quality)
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", 8)
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("tile_rows", 0)
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('utf-8')
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
- advanced = tuple([
178
- (str(k).encode("utf-8"), str(v).encode("utf-8"))
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
@@ -1,5 +1,5 @@
1
1
  from . import AvifImagePlugin
2
2
 
3
3
 
4
- __all__ = ['AvifImagePlugin']
5
- __version__ = '1.2.2'
4
+ __all__ = ["AvifImagePlugin"]
5
+ __version__ = "1.4.4"
Binary file
@@ -258,6 +258,41 @@ LIBGAV1
258
258
  limitations under the License.
259
259
 
260
260
 
261
+ ----
262
+
263
+ LIBYUV
264
+
265
+ Copyright 2011 The LibYuv Project Authors. All rights reserved.
266
+
267
+ Redistribution and use in source and binary forms, with or without
268
+ modification, are permitted provided that the following conditions are
269
+ met:
270
+
271
+ * Redistributions of source code must retain the above copyright
272
+ notice, this list of conditions and the following disclaimer.
273
+
274
+ * Redistributions in binary form must reproduce the above copyright
275
+ notice, this list of conditions and the following disclaimer in
276
+ the documentation and/or other materials provided with the
277
+ distribution.
278
+
279
+ * Neither the name of Google nor the names of its contributors may
280
+ be used to endorse or promote products derived from this software
281
+ without specific prior written permission.
282
+
283
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
284
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
285
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
286
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
287
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
288
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
289
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
290
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
291
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
292
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
293
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
294
+
295
+
261
296
  ----
262
297
 
263
298
  RAV1E
@@ -1,13 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pillow-avif-plugin
3
- Version: 1.2.2
3
+ Version: 1.4.4
4
4
  Summary: A pillow plugin that adds avif support via libavif
5
5
  Home-page: https://github.com/fdintino/pillow-avif-plugin/
6
6
  Download-URL: https://github.com/fdintino/pillow-avif-plugin/releases
7
7
  Author: Frankie Dintino
8
8
  Author-email: fdintino@theatlantic.com
9
9
  License: MIT License
10
- Platform: UNKNOWN
11
10
  Classifier: Development Status :: 5 - Production/Stable
12
11
  Classifier: Environment :: Web Environment
13
12
  Classifier: Intended Audience :: Developers
@@ -17,11 +16,12 @@ Classifier: Programming Language :: C
17
16
  Classifier: Programming Language :: C++
18
17
  Classifier: Programming Language :: Python :: 2.7
19
18
  Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.6
21
19
  Classifier: Programming Language :: Python :: 3.7
22
20
  Classifier: Programming Language :: Python :: 3.8
23
21
  Classifier: Programming Language :: Python :: 3.9
24
22
  Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
25
  Classifier: Programming Language :: Python :: Implementation :: CPython
26
26
  Classifier: Programming Language :: Python :: Implementation :: PyPy
27
27
  Classifier: Topic :: Multimedia :: Graphics
@@ -34,5 +34,3 @@ License-File: LICENSE
34
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
35
 
36
36
  To register this plugin with pillow you will need to add `import pillow_avif` somewhere in your application.
37
-
38
-
@@ -0,0 +1,9 @@
1
+ pillow_avif/AvifImagePlugin.py,sha256=MfIVDuN7jVDceVl68b9R5lTHxzrHG6wpt6Ca-NbFdAw,8486
2
+ pillow_avif/__init__.py,sha256=WQFEMp706st11VAv63ZKU1Detvxgq6CAyL3AySmoJAs,84
3
+ pillow_avif/_avif.cpython-37m-darwin.so,sha256=uW2Zg3ZufF6FML_PkHSpXYGg6pm5jmkfbeDRU7UpTmA,24810792
4
+ pillow_avif_plugin-1.4.4.dist-info/LICENSE,sha256=2l49eVdgaNy9JTEPbstz1GaaPKw02gFdtuThTNUi730,25213
5
+ pillow_avif_plugin-1.4.4.dist-info/METADATA,sha256=0a9T5wIn2CbcqytY96XPXOZYQ9t6mqpV6PwH_eDbWYQ,1668
6
+ pillow_avif_plugin-1.4.4.dist-info/WHEEL,sha256=HfXAYhgQ34BhcNt1Y83kqt02hxEE-KNvttiJH3T5IsM,111
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=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
+ pillow_avif_plugin-1.4.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.1)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp37-cp37m-macosx_10_10_x86_64
5
5
 
Binary file
Binary file
Binary file
Binary file
@@ -1,16 +0,0 @@
1
- pillow_avif_plugin-1.2.2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
- pillow_avif_plugin-1.2.2.dist-info/RECORD,,
3
- pillow_avif_plugin-1.2.2.dist-info/LICENSE,sha256=Y-GPM2BDn_PNAiKqwHfB2ubsfRy0GSy4Y_0XqT_80Sg,23691
4
- pillow_avif_plugin-1.2.2.dist-info/WHEEL,sha256=skNqN-ggnyfJIwZg4zPa58wZKk7PZBGkMiXnAznkIu4,111
5
- pillow_avif_plugin-1.2.2.dist-info/top_level.txt,sha256=xrg4zRnqDyl_JEyEQh3oCcAU4BHneocD-DCFDzf4g9E,12
6
- pillow_avif_plugin-1.2.2.dist-info/METADATA,sha256=XNgTWgeMvz2n2oiQuA0M0_lv28BHyTcAXc1S8SA5Mmg,1636
7
- pillow_avif/AvifImagePlugin.py,sha256=J-a1lf1yj7RqH9ZI7_WEMCAuG77ofcek_f5GtiY_auc,8177
8
- pillow_avif/__init__.py,sha256=KjJsqr2XKw0ZJsUUdN5M5bRoIISUDzap1R6Pk5H75J4,84
9
- pillow_avif/_avif.cpython-37m-darwin.so,sha256=8hDyZ74dAv0OnHHgiH82nJjAFlv2sWTDz8oqY0oMXyU,58768
10
- pillow_avif/.dylibs/libvmaf.1.dylib,sha256=v8ncAM-8HJCo-SZosucYrTad31f6ifV35Wrg2_GFCoo,883376
11
- pillow_avif/.dylibs/libaom.3.3.0.dylib,sha256=5X0yeXsgJrAkD6X0w2QA9DhApNz3k5pQ-aGrrOwp9JU,5608000
12
- pillow_avif/.dylibs/libbrotlienc.1.0.9.dylib,sha256=BXy1Q64D9uACKg4a6or1DYu7CY4li10N-9a7x_tuLVE,601200
13
- pillow_avif/.dylibs/libavif.14.0.1.dylib,sha256=U-1W46eMLXUDxUMyJt7N28EcWHO_6YoQqXA7yN9G5dc,15895328
14
- pillow_avif/.dylibs/libbrotlidec.1.0.9.dylib,sha256=wOqDdWuVLPz2bHPeQwl1xE59XZxobqkDW7Z4_Ai4Ezc,71216
15
- pillow_avif/.dylibs/libbrotlicommon.1.0.9.dylib,sha256=DKEXX3UWu07Wo6LLXY2DdSzPLu05v02dltUoqCEgSuc,159632
16
- pillow_avif/.dylibs/libjxl.0.6.1.dylib,sha256=enNqwiPbO4SGDWklbS91gm4Vad5Zq1IEOV0R27kzj-E,2635136