mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-09 23:53:17 +03:00
Merge c86aa57ee8
into 06e618c470
This commit is contained in:
commit
1a17a0c0e6
|
@ -53,12 +53,9 @@ def _accept(prefix: bytes) -> bool | str:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _get_default_max_threads() -> int:
|
def _get_max_threads() -> int:
|
||||||
if DEFAULT_MAX_THREADS:
|
|
||||||
return DEFAULT_MAX_THREADS
|
|
||||||
if hasattr(os, "sched_getaffinity"):
|
if hasattr(os, "sched_getaffinity"):
|
||||||
return len(os.sched_getaffinity(0))
|
return len(os.sched_getaffinity(0))
|
||||||
else:
|
|
||||||
return os.cpu_count() or 1
|
return os.cpu_count() or 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +77,7 @@ class AvifImageFile(ImageFile.ImageFile):
|
||||||
self._decoder = _avif.AvifDecoder(
|
self._decoder = _avif.AvifDecoder(
|
||||||
self.fp.read(),
|
self.fp.read(),
|
||||||
DECODE_CODEC_CHOICE,
|
DECODE_CODEC_CHOICE,
|
||||||
_get_default_max_threads(),
|
DEFAULT_MAX_THREADS or _get_max_threads(),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get info from decoder
|
# Get info from decoder
|
||||||
|
@ -163,7 +160,7 @@ def _save(
|
||||||
duration = info.get("duration", 0)
|
duration = info.get("duration", 0)
|
||||||
subsampling = info.get("subsampling", "4:2:0")
|
subsampling = info.get("subsampling", "4:2:0")
|
||||||
speed = info.get("speed", 6)
|
speed = info.get("speed", 6)
|
||||||
max_threads = info.get("max_threads", _get_default_max_threads())
|
max_threads = info.get("max_threads", _get_max_threads())
|
||||||
codec = info.get("codec", "auto")
|
codec = info.get("codec", "auto")
|
||||||
if codec != "auto" and not _avif.encoder_codec_available(codec):
|
if codec != "auto" and not _avif.encoder_codec_available(codec):
|
||||||
msg = "Invalid saving codec"
|
msg = "Invalid saving codec"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user