fix: allow docs previews without pillow
This commit is contained in:
@@ -17,8 +17,6 @@ from pathlib import Path
|
|||||||
from typing import TYPE_CHECKING, Optional, Sequence, Tuple
|
from typing import TYPE_CHECKING, Optional, Sequence, Tuple
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
from PIL import Image, ImageOps, UnidentifiedImageError
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from bot.middlewares.i18n import JsonI18n
|
from bot.middlewares.i18n import JsonI18n
|
||||||
from config.settings import Settings
|
from config.settings import Settings
|
||||||
@@ -154,6 +152,11 @@ def _email_logo_payload(filename: str, content_type: str, body: bytes) -> Tuple[
|
|||||||
|
|
||||||
|
|
||||||
def _static_raster_logo_to_png(body: bytes) -> Optional[bytes]:
|
def _static_raster_logo_to_png(body: bytes) -> Optional[bytes]:
|
||||||
|
try:
|
||||||
|
from PIL import Image, ImageOps, UnidentifiedImageError
|
||||||
|
except ImportError:
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with Image.open(io.BytesIO(body)) as image:
|
with Image.open(io.BytesIO(body)) as image:
|
||||||
image.seek(0)
|
image.seek(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user