Improved compression
This commit is contained in:
parent
4892916e16
commit
5a139c075c
7
dependencies.md
Normal file
7
dependencies.md
Normal 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
|
@ -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}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user