diff --git a/esphome/components/animation/__init__.py b/esphome/components/animation/__init__.py index 52e14f0a4..9151d6e56 100644 --- a/esphome/components/animation/__init__.py +++ b/esphome/components/animation/__init__.py @@ -151,7 +151,7 @@ async def to_code(config): pos = 0 for frameIndex in range(frames): image.seek(frameIndex) - frame = image.convert("LA", dither=Image.NONE) + frame = image.convert("LA", dither=Image.Dither.NONE) if CONF_RESIZE in config: frame = frame.resize([width, height]) pixels = list(frame.getdata()) @@ -259,7 +259,7 @@ async def to_code(config): if transparent: alpha = image.split()[-1] has_alpha = alpha.getextrema()[0] < 0xFF - frame = image.convert("1", dither=Image.NONE) + frame = image.convert("1", dither=Image.Dither.NONE) if CONF_RESIZE in config: frame = frame.resize([width, height]) if transparent: diff --git a/esphome/components/font/__init__.py b/esphome/components/font/__init__.py index e6244d8d4..2bd6beeae 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -67,18 +67,13 @@ def validate_pillow_installed(value): except ImportError as err: raise cv.Invalid( "Please install the pillow python package to use this feature. " - '(pip install pillow">4.0.0,<10.0.0")' + '(pip install "pillow==10.0.1")' ) from err - if version.parse(PIL.__version__) < version.parse("4.0.0"): + if version.parse(PIL.__version__) != version.parse("10.0.1"): raise cv.Invalid( - "Please update your pillow installation to at least 4.0.x. " - '(pip install pillow">4.0.0,<10.0.0")' - ) - if version.parse(PIL.__version__) >= version.parse("10.0.0"): - raise cv.Invalid( - "Please downgrade your pillow installation to below 10.0.0. " - '(pip install pillow">4.0.0,<10.0.0")' + "Please update your pillow installation to 10.0.1. " + '(pip install "pillow==10.0.1")' ) return value diff --git a/esphome/components/ili9xxx/display.py b/esphome/components/ili9xxx/display.py index 1a18978d9..241f56e01 100644 --- a/esphome/components/ili9xxx/display.py +++ b/esphome/components/ili9xxx/display.py @@ -1,7 +1,7 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome import core, pins -from esphome.components import display, spi +from esphome.components import display, spi, font from esphome.core import CORE, HexInt from esphome.const import ( CONF_COLOR_PALETTE, @@ -84,6 +84,7 @@ def _validate(config): CONFIG_SCHEMA = cv.All( + font.validate_pillow_installed, display.FULL_DISPLAY_SCHEMA.extend( { cv.GenerateID(): cv.declare_id(ili9XXXSPI), @@ -162,7 +163,7 @@ async def to_code(config): x = x + i.width # reduce the colors on combined image to 256. - converted = ref_image.convert("P", palette=Image.ADAPTIVE, colors=256) + converted = ref_image.convert("P", palette=Image.Palette.ADAPTIVE, colors=256) # if you want to verify how the images look use # ref_image.save("ref_in.png") # converted.save("ref_out.png") diff --git a/esphome/components/image/__init__.py b/esphome/components/image/__init__.py index aa402ee32..1b7c654b0 100644 --- a/esphome/components/image/__init__.py +++ b/esphome/components/image/__init__.py @@ -255,7 +255,11 @@ async def to_code(config): transparent = config[CONF_USE_TRANSPARENCY] - dither = Image.NONE if config[CONF_DITHER] == "NONE" else Image.FLOYDSTEINBERG + dither = ( + Image.Dither.NONE + if config[CONF_DITHER] == "NONE" + else Image.Dither.FLOYDSTEINBERG + ) if config[CONF_TYPE] == "GRAYSCALE": image = image.convert("LA", dither=dither) pixels = list(image.getdata()) diff --git a/requirements_optional.txt b/requirements_optional.txt index 8bbf0a680..236f5e3f1 100644 --- a/requirements_optional.txt +++ b/requirements_optional.txt @@ -1,3 +1,3 @@ -pillow>4.0.0,<10.0.0 +pillow==10.0.1 cairosvg>=2.2.0 cryptography>=2.0.0,<4 diff --git a/tests/test2.yaml b/tests/test2.yaml index fe577c218..fe1ad91f8 100644 --- a/tests/test2.yaml +++ b/tests/test2.yaml @@ -760,6 +760,11 @@ image: file: mdi:alert-outline type: BINARY +font: + - file: "gfonts://Roboto" + id: roboto + size: 20 + graph: - id: my_graph sensor: ha_hello_world_temperature