FFMpeg-Compressor: FallBackExtension parameter

This commit is contained in:
OleSTEEP 2023-11-28 19:07:09 +03:00
parent 2f31c22d91
commit e70dd56142
3 changed files with 5 additions and 3 deletions

View file

@ -62,11 +62,11 @@ def compress_image(folder, file, target_folder, extension):
image = Image.open(f'{folder}/{file}')
if (extension == "jpg" or extension == "jpeg" or
if (extension == "jpg" or extension == "jpeg" or extension == "avif" or
(extension == "webp" and not configloader.config['FFMPEG']['WebpRGBA'])):
if has_transparency(Image.open(f'{folder}/{file}')):
printer.warning(f"{file} has transparency. Changing to png...")
extension = ".png"
printer.warning(f"{file} has transparency. Changing to fallback...")
extension = configloader.config['IMAGE']['FallBackExtension']
printer.files(file, os.path.splitext(file)[0], extension, f"{quality}%")
image.save(f"{target_folder}/{os.path.splitext(file)[0]}.{extension}",