mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 00:18:11 +01:00
Move to Pillow 10.x (#5489)
Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
e09c217fde
commit
412a866de8
6 changed files with 20 additions and 15 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
pillow>4.0.0,<10.0.0
|
||||
pillow==10.0.1
|
||||
cairosvg>=2.2.0
|
||||
cryptography>=2.0.0,<4
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue