From 436611a5b4e766fa1a811e50ed1e3c1771bfc2af Mon Sep 17 00:00:00 2001 From: Llloooggg Date: Fri, 16 May 2025 03:35:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=D0=B5=D1=81=D0=B0=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- image_compressor.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/image_compressor.py b/image_compressor.py index 6c7bab1..f7568e0 100644 --- a/image_compressor.py +++ b/image_compressor.py @@ -131,24 +131,24 @@ def convert_png_to_jpeg(path: Path) -> Optional[Path]: def compress_with_external( path: Path, ext: str ) -> Tuple[Optional[bool], Path]: + exif = extract_exif(path) original_size = path.stat().st_size tmp_path = path.with_name(path.stem + ".compressed" + path.suffix) - exif = extract_exif(path) try: if ext == ".png": converted = convert_png_to_jpeg(path) if not converted: return False, path - conerted_size = converted.stat().st_size + converted_size = converted.stat().st_size logging.warning( - f"Сконвертирован PNG в JPEG: {path} ({original_size // 1024} KB) -> {converted} ({conerted_size // 1024} KB)" + f"Сконвертирован PNG в JPEG: {path} ({original_size // 1024} KB) -> {converted} ({converted_size // 1024} KB)" ) - if conerted_size < TARGET_SIZE: + if converted_size <= TARGET_SIZE: return True, converted path = converted ext = ".jpg" - original_size = conerted_size + original_size = converted_size if ext in [".jpg", ".jpeg"]: tool = get_tool_path("cjpeg-static.exe") args_base = [ @@ -217,9 +217,9 @@ def compress_with_external( def compress_with_pillow(path: Path) -> Tuple[bool, Path]: + exif = extract_exif(path) original_size = path.stat().st_size tmp_path = path.with_name(path.stem + ".pillowtmp" + path.suffix) - exif = extract_exif(path) try: with Image.open(path) as img: