mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 11:47:30 +01:00
[image] Make PIL import local (#6864)
This commit is contained in:
parent
e2784d077d
commit
699d00e218
@ -9,8 +9,6 @@ import re
|
||||
import requests
|
||||
from magic import Magic
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from esphome import core
|
||||
from esphome.components import font
|
||||
from esphome import external_files
|
||||
@ -267,6 +265,9 @@ CONFIG_SCHEMA = cv.All(font.validate_pillow_installed, IMAGE_SCHEMA)
|
||||
|
||||
|
||||
def load_svg_image(file: bytes, resize: tuple[int, int]):
|
||||
# Local import only to allow "validate_pillow_installed" to run *before* importing it
|
||||
from PIL import Image
|
||||
|
||||
# This import is only needed in case of SVG images; adding it
|
||||
# to the top would force configurations not using SVG to also have it
|
||||
# installed for no reason.
|
||||
@ -286,6 +287,9 @@ def load_svg_image(file: bytes, resize: tuple[int, int]):
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
# Local import only to allow "validate_pillow_installed" to run *before* importing it
|
||||
from PIL import Image
|
||||
|
||||
conf_file = config[CONF_FILE]
|
||||
|
||||
if conf_file[CONF_SOURCE] == SOURCE_LOCAL:
|
||||
|
Loading…
Reference in New Issue
Block a user