From d113220501dec500d17cbf06ff6e7b79a47fe7a3 Mon Sep 17 00:00:00 2001 From: Simon Shi Date: Sat, 4 Jan 2025 15:58:19 +0800 Subject: [PATCH] fix compress --- biliparser/strategy/video.py | 7 +++---- biliparser/utils.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/biliparser/strategy/video.py b/biliparser/strategy/video.py index bd00ad7..15c778b 100644 --- a/biliparser/strategy/video.py +++ b/biliparser/strategy/video.py @@ -1,9 +1,10 @@ -from math import log import os import re from functools import cached_property +from urllib.parse import parse_qs, urlparse import orjson +from bilibili_api import video from telegram.constants import FileSizeLimit from ..cache import CACHES_TIMER, RedisCache @@ -11,15 +12,13 @@ BILI_API, LOCAL_MODE, ParserException, + credential, escape_markdown, get_filename, headers, logger, - credential, ) from .feed import Feed -from bilibili_api import video -from urllib.parse import urlparse, parse_qs QN = [64, 32, 16] diff --git a/biliparser/utils.py b/biliparser/utils.py index 72ff239..20fadaf 100644 --- a/biliparser/utils.py +++ b/biliparser/utils.py @@ -71,6 +71,7 @@ def compress(inpil, size=1280, fix_ratio=False) -> BytesIO: new_w = math.ceil(h / 20) padded = Image.new("RGBA", (new_w, h)) padded.paste(pil, (int((new_w - h) / 2), 0)) + pil = padded if size > 0: pil.thumbnail((size, size), Image.Resampling.LANCZOS) outpil = BytesIO()