Improved compression

This commit is contained in:
Profitroll 2022-12-20 22:52:05 +01:00
parent 4892916e16
commit 5a139c075c
2 changed files with 10 additions and 1 deletions

7
dependencies.md Normal file
View File

@ -0,0 +1,7 @@
# Dependecies
In order to get compression to work you need to install following binaries and make them directly available on your machine:
* exiftool
* jpegoptim
* optipng

View File

@ -29,8 +29,10 @@ async def compress_image(image_path: str):
size_before = path.getsize(image_path) / 1024 size_before = path.getsize(image_path) / 1024
system(f"exiftool -overwrite_original -all:all= -tagsFromFile @ -exif:Orientation {image_path}")
if image_type == "image/jpeg": if image_type == "image/jpeg":
system(f"jpegoptim {image_path} -o --max=60 --strip-all") system(f"jpegoptim {image_path} -o --max=55 -p")
elif image_type == "image/png": elif image_type == "image/png":
system(f"optipng -o3 {image_path}") system(f"optipng -o3 {image_path}")