pillow-avif-plugin 1.4.0__cp311-cp311-win_amd64.whl → 1.4.2__cp311-cp311-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.

@@ -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
@@ -56,6 +56,9 @@ class AvifImageFile(ImageFile.ImageFile):
56
56
  __loaded = -1
57
57
  __frame = 0
58
58
 
59
+ def load_seek(self, pos):
60
+ pass
61
+
59
62
  def _open(self):
60
63
  self._decoder = _avif.AvifDecoder(
61
64
  self.fp.read(), DECODE_CODEC_CHOICE, CHROMA_UPSAMPLING
@@ -126,23 +129,11 @@ def _save(im, fp, filename, save_all=False):
126
129
 
127
130
  is_single_frame = total == 1
128
131
 
129
- qmin = info.get("qmin")
130
- qmax = info.get("qmax")
131
-
132
- if qmin is None and qmax is None:
133
- # The min and max quantizer settings in libavif range from 0 (best quality)
134
- # to 63 (worst quality). If neither are explicitly specified, we use a 0-100
135
- # quality scale (default 75) and calculate the qmin and qmax from that.
136
- #
137
- # - qmin is 0 for quality >= 64. Below that, qmin has an inverse linear
138
- # relation to quality (i.e., quality 63 = qmin 1, quality 0 => qmin 63)
139
- # - qmax is 0 for quality=100, then qmax increases linearly relative to
140
- # quality decreasing, until it flattens out at quality=37.
141
- quality = info.get("quality", 75)
142
- if not isinstance(quality, int) or quality < 0 or quality > 100:
143
- raise ValueError("Invalid quality setting")
144
- qmin = max(0, min(64 - quality, 63))
145
- qmax = max(0, min(100 - quality, 63))
132
+ qmin = info.get("qmin", -1)
133
+ qmax = info.get("qmax", -1)
134
+ quality = info.get("quality", 75)
135
+ if not isinstance(quality, int) or quality < 0 or quality > 100:
136
+ raise ValueError("Invalid quality setting")
146
137
 
147
138
  duration = info.get("duration", 0)
148
139
  subsampling = info.get("subsampling", "4:2:0")
@@ -158,6 +149,20 @@ def _save(im, fp, filename, save_all=False):
158
149
  exif = info.get("exif", im.info.get("exif"))
159
150
  if isinstance(exif, Image.Exif):
160
151
  exif = exif.tobytes()
152
+
153
+ exif_orientation = 0
154
+ if exif:
155
+ exif_data = Image.Exif()
156
+ try:
157
+ exif_data.load(exif)
158
+ except SyntaxError:
159
+ pass
160
+ else:
161
+ orientation_tag = next(
162
+ k for k, v in ExifTags.TAGS.items() if v == "Orientation"
163
+ )
164
+ exif_orientation = exif_data.get(orientation_tag) or 0
165
+
161
166
  xmp = info.get("xmp", im.info.get("xmp") or im.info.get("XML:com.adobe.xmp"))
162
167
 
163
168
  if isinstance(xmp, text_type):
@@ -199,6 +204,7 @@ def _save(im, fp, filename, save_all=False):
199
204
  autotiling,
200
205
  icc_profile or b"",
201
206
  exif or b"",
207
+ exif_orientation,
202
208
  xmp or b"",
203
209
  advanced,
204
210
  )
pillow_avif/__init__.py CHANGED
@@ -2,4 +2,4 @@ from . import AvifImagePlugin
2
2
 
3
3
 
4
4
  __all__ = ["AvifImagePlugin"]
5
- __version__ = "1.4.0"
5
+ __version__ = "1.4.2"
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pillow-avif-plugin
3
- Version: 1.4.0
3
+ Version: 1.4.2
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
@@ -0,0 +1,9 @@
1
+ pillow_avif/AvifImagePlugin.py,sha256=lAVnA30X0re_zar8Wp0-Z9grIVZMqv60sH0HHbetExg,8454
2
+ pillow_avif/__init__.py,sha256=w35Kp0HjjsncSa3zlLn6KnuWPnlleTQYrof72XFBl6E,89
3
+ pillow_avif/_avif.cp311-win_amd64.pyd,sha256=mL79S3piABA86JDgIDcN23zFDHjIwad7V29yURRqfqo,26011648
4
+ pillow_avif_plugin-1.4.2.dist-info/LICENSE,sha256=tubzK3TFrT8GFgUPEKC-WmCziD1dGOFLCjDky3t9Lnc,1321
5
+ pillow_avif_plugin-1.4.2.dist-info/METADATA,sha256=0AIciESg0g1L8OIm03rgTEFiPAsT3JK5jXEdRiD3AQk,1704
6
+ pillow_avif_plugin-1.4.2.dist-info/WHEEL,sha256=ircjsfhzblqgSzO8ow7-0pXK-RVqDqNRGQ8F650AUNM,102
7
+ pillow_avif_plugin-1.4.2.dist-info/top_level.txt,sha256=xrg4zRnqDyl_JEyEQh3oCcAU4BHneocD-DCFDzf4g9E,12
8
+ pillow_avif_plugin-1.4.2.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
9
+ pillow_avif_plugin-1.4.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp311-cp311-win_amd64
5
5
 
@@ -1,9 +0,0 @@
1
- pillow_avif/AvifImagePlugin.py,sha256=BYBYS9qD5JUoRQPA7Nrr4asqeyRq_BXKqj1_Sy3O0gk,8703
2
- pillow_avif/__init__.py,sha256=_ASToIhzqkCoKaYCNv1DUdt_zrIO-tcI1ubuxMaDos4,89
3
- pillow_avif/_avif.cp311-win_amd64.pyd,sha256=LCkyk1woyBIbyWUZJd-kypsDR6JdKPAwTM_NcROAKrk,26011136
4
- pillow_avif_plugin-1.4.0.dist-info/LICENSE,sha256=tubzK3TFrT8GFgUPEKC-WmCziD1dGOFLCjDky3t9Lnc,1321
5
- pillow_avif_plugin-1.4.0.dist-info/METADATA,sha256=TATphSXrFm1CtSybbOYQ90GxvAtZNBxd7rmgzJfGuvA,1704
6
- pillow_avif_plugin-1.4.0.dist-info/WHEEL,sha256=badvNS-y9fEq0X-qzdZYvql_JFjI7Xfw-wR8FsjoK0I,102
7
- pillow_avif_plugin-1.4.0.dist-info/top_level.txt,sha256=xrg4zRnqDyl_JEyEQh3oCcAU4BHneocD-DCFDzf4g9E,12
8
- pillow_avif_plugin-1.4.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
9
- pillow_avif_plugin-1.4.0.dist-info/RECORD,,