pillow-avif-plugin 1.3.0__tar.gz → 1.4.0__tar.gz

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.

@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021, Frankie Dintino. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are met:
5
+
6
+ * Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,18 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pillow-avif-plugin
3
- Version: 1.3.0
3
+ Version: 1.4.0
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
  Author: Frankie Dintino
7
7
  Author-email: fdintino@theatlantic.com
8
8
  License: MIT License
9
9
  Download-URL: https://github.com/fdintino/pillow-avif-plugin/releases
10
- Description: # pillow-avif-plugin
11
-
12
- 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)).
13
-
14
- To register this plugin with pillow you will need to add `import pillow_avif` somewhere in your application.
15
-
16
10
  Platform: UNKNOWN
17
11
  Classifier: Development Status :: 5 - Production/Stable
18
12
  Classifier: Environment :: Web Environment
@@ -23,14 +17,23 @@ Classifier: Programming Language :: C
23
17
  Classifier: Programming Language :: C++
24
18
  Classifier: Programming Language :: Python :: 2.7
25
19
  Classifier: Programming Language :: Python :: 3
26
- Classifier: Programming Language :: Python :: 3.6
27
20
  Classifier: Programming Language :: Python :: 3.7
28
21
  Classifier: Programming Language :: Python :: 3.8
29
22
  Classifier: Programming Language :: Python :: 3.9
30
23
  Classifier: Programming Language :: Python :: 3.10
31
24
  Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
32
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
33
27
  Classifier: Programming Language :: Python :: Implementation :: PyPy
34
28
  Classifier: Topic :: Multimedia :: Graphics
35
29
  Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
36
30
  Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+
33
+ # pillow-avif-plugin
34
+
35
+ 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)).
36
+
37
+ To register this plugin with pillow you will need to add `import pillow_avif` somewhere in your application.
38
+
39
+
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
@@ -61,12 +61,12 @@ setup(
61
61
  "Programming Language :: C++",
62
62
  "Programming Language :: Python :: 2.7",
63
63
  "Programming Language :: Python :: 3",
64
- "Programming Language :: Python :: 3.6",
65
64
  "Programming Language :: Python :: 3.7",
66
65
  "Programming Language :: Python :: 3.8",
67
66
  "Programming Language :: Python :: 3.9",
68
67
  "Programming Language :: Python :: 3.10",
69
68
  "Programming Language :: Python :: 3.11",
69
+ "Programming Language :: Python :: 3.12",
70
70
  "Programming Language :: Python :: Implementation :: CPython",
71
71
  "Programming Language :: Python :: Implementation :: PyPy",
72
72
  "Topic :: Multimedia :: Graphics",
@@ -51,7 +51,6 @@ def _accept(prefix):
51
51
 
52
52
 
53
53
  class AvifImageFile(ImageFile.ImageFile):
54
-
55
54
  format = "AVIF"
56
55
  format_description = "AVIF image"
57
56
  __loaded = -1
@@ -67,7 +66,10 @@ class AvifImageFile(ImageFile.ImageFile):
67
66
  self._size = width, height
68
67
  self.n_frames = n_frames
69
68
  self.is_animated = self.n_frames > 1
70
- self.mode = self.rawmode = mode
69
+ try:
70
+ self.mode = self.rawmode = mode
71
+ except AttributeError:
72
+ self._mode = self.rawmode = mode
71
73
  self.tile = []
72
74
 
73
75
  if icc:
@@ -137,7 +139,7 @@ def _save(im, fp, filename, save_all=False):
137
139
  # - qmax is 0 for quality=100, then qmax increases linearly relative to
138
140
  # quality decreasing, until it flattens out at quality=37.
139
141
  quality = info.get("quality", 75)
140
- if not isinstance(quality, int):
142
+ if not isinstance(quality, int) or quality < 0 or quality > 100:
141
143
  raise ValueError("Invalid quality setting")
142
144
  qmin = max(0, min(64 - quality, 63))
143
145
  qmax = max(0, min(100 - quality, 63))
@@ -187,6 +189,7 @@ def _save(im, fp, filename, save_all=False):
187
189
  subsampling,
188
190
  qmin,
189
191
  qmax,
192
+ quality,
190
193
  speed,
191
194
  codec,
192
195
  range_,
@@ -2,4 +2,4 @@ from . import AvifImagePlugin
2
2
 
3
3
 
4
4
  __all__ = ["AvifImagePlugin"]
5
- __version__ = "1.3.0"
5
+ __version__ = "1.4.0"
@@ -13,6 +13,7 @@ typedef struct {
13
13
  avifPixelFormat subsampling;
14
14
  int qmin;
15
15
  int qmax;
16
+ int quality;
16
17
  int speed;
17
18
  avifCodecChoice codec;
18
19
  avifRange range;
@@ -205,6 +206,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
205
206
  char *subsampling = "4:2:0";
206
207
  int qmin = AVIF_QUANTIZER_BEST_QUALITY; // =0
207
208
  int qmax = 10; // "High Quality", but not lossless
209
+ int quality = 75;
208
210
  int speed = 8;
209
211
  PyObject *icc_bytes;
210
212
  PyObject *exif_bytes;
@@ -221,12 +223,13 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
221
223
 
222
224
  if (!PyArg_ParseTuple(
223
225
  args,
224
- "IIsiiissiiOOSSSO",
226
+ "IIsiiiissiiOOSSSO",
225
227
  &width,
226
228
  &height,
227
229
  &subsampling,
228
230
  &qmin,
229
231
  &qmax,
232
+ &quality,
230
233
  &speed,
231
234
  &codec,
232
235
  &range,
@@ -256,6 +259,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
256
259
 
257
260
  enc_options.qmin = normalize_quantize_value(qmin);
258
261
  enc_options.qmax = normalize_quantize_value(qmax);
262
+ enc_options.quality = quality;
259
263
 
260
264
  if (speed < AVIF_SPEED_SLOWEST) {
261
265
  speed = AVIF_SPEED_SLOWEST;
@@ -321,8 +325,12 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
321
325
  }
322
326
 
323
327
  encoder->maxThreads = max_threads;
328
+ #if AVIF_VERSION >= 1000000
329
+ encoder->quality = enc_options.quality;
330
+ #else
324
331
  encoder->minQuantizer = enc_options.qmin;
325
332
  encoder->maxQuantizer = enc_options.qmax;
333
+ #endif
326
334
  encoder->codecChoice = enc_options.codec;
327
335
  encoder->speed = enc_options.speed;
328
336
  encoder->timescale = (uint64_t)1000;
@@ -1,18 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pillow-avif-plugin
3
- Version: 1.3.0
3
+ Version: 1.4.0
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
  Author: Frankie Dintino
7
7
  Author-email: fdintino@theatlantic.com
8
8
  License: MIT License
9
9
  Download-URL: https://github.com/fdintino/pillow-avif-plugin/releases
10
- Description: # pillow-avif-plugin
11
-
12
- 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)).
13
-
14
- To register this plugin with pillow you will need to add `import pillow_avif` somewhere in your application.
15
-
16
10
  Platform: UNKNOWN
17
11
  Classifier: Development Status :: 5 - Production/Stable
18
12
  Classifier: Environment :: Web Environment
@@ -23,14 +17,23 @@ Classifier: Programming Language :: C
23
17
  Classifier: Programming Language :: C++
24
18
  Classifier: Programming Language :: Python :: 2.7
25
19
  Classifier: Programming Language :: Python :: 3
26
- Classifier: Programming Language :: Python :: 3.6
27
20
  Classifier: Programming Language :: Python :: 3.7
28
21
  Classifier: Programming Language :: Python :: 3.8
29
22
  Classifier: Programming Language :: Python :: 3.9
30
23
  Classifier: Programming Language :: Python :: 3.10
31
24
  Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
32
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
33
27
  Classifier: Programming Language :: Python :: Implementation :: PyPy
34
28
  Classifier: Topic :: Multimedia :: Graphics
35
29
  Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
36
30
  Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+
33
+ # pillow-avif-plugin
34
+
35
+ 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)).
36
+
37
+ To register this plugin with pillow you will need to add `import pillow_avif` somewhere in your application.
38
+
39
+
@@ -1,5 +1,7 @@
1
+ LICENSE
1
2
  MANIFEST.in
2
3
  README.md
4
+ pyproject.toml
3
5
  setup.cfg
4
6
  setup.py
5
7
  tox.ini
@@ -1,21 +1,26 @@
1
1
  [tox]
2
- envlist = py{27,36,37,38,39,310,py27,py36,py37}
2
+ envlist = py{27,37,38,39,310,311,312,py37}
3
3
  minversion = 1.9
4
4
 
5
5
  [gh-actions]
6
+ problem_matcher = False
6
7
  python =
7
8
  2.7: py27
8
- 3.6: py36
9
9
  3.7: py37
10
10
  3.8: py38
11
11
  3.9: py39
12
12
  3.10: py310
13
- pypy-2.7: pypy27
14
- pypy-3.6: pypy36
13
+ 3.11: py311
14
+ 3.12: py312
15
15
  pypy-3.7: pypy37
16
16
 
17
17
  [testenv]
18
- passenv = LDFLAGS CFLAGS LD_LIBRARY_PATH TERM CC
18
+ passenv =
19
+ LDFLAGS
20
+ CFLAGS
21
+ LD_LIBRARY_PATH
22
+ TERM
23
+ CC
19
24
  use_develop = true
20
25
  skip_install = true
21
26
  setenv =
@@ -24,13 +29,12 @@ setenv =
24
29
  GCNO_TARGET_DIR={envdir}/temp
25
30
  COVERAGE_FILE={toxworkdir}/coverage/.coverage.{envname}
26
31
  commands =
27
- {envpython} setup.py clean
28
- {envpython} setup.py build_ext --build-lib {envdir}/src --build-temp {envdir} develop
32
+ {envpython} -m pip install -e . -v
29
33
  {envpython} -m pytest -W always {posargs: -vv --cov pillow_avif --cov tests --cov-report term}
30
- gcovr -r {toxinidir} --object-directory {envdir} -k
31
34
  {envpython} -c "import os; os.path.exists('{toxworkdir}/coverage') or os.makedirs('{toxworkdir}/coverage')"
32
- gcovr -r {toxinidir} --object-directory {envdir} -k --xml \
33
- -o {toxworkdir}/coverage/gcov_coverage.{envname}.xml
35
+ - gcovr -r {toxinidir} --object-directory {envdir} -k \
36
+ --gcov-ignore-errors=no_working_dir_found \
37
+ -o {toxworkdir}/coverage/.gcov_coverage.{envname}
34
38
  deps =
35
39
  gcovr
36
40
  pytest
@@ -48,7 +52,7 @@ changedir = {toxworkdir}/coverage
48
52
  commands =
49
53
  coverage combine
50
54
  coverage report
51
- coverage xml
55
+ coverage xml -o {toxinidir}/coverage.xml
52
56
 
53
57
  [testenv:codecov]
54
58
  skip_install = true
@@ -57,4 +61,4 @@ depends = coverage-report
57
61
  passenv = CODECOV_TOKEN
58
62
  changedir = {toxinidir}
59
63
  commands =
60
- codecov -X gcov --file {toxworkdir}/coverage/*.xml {posargs}
64
+ codecov -X gcov --file {toxinidir}/coverage.xml {posargs}