Created
February 12, 2023 21:09
-
-
Save ProGamerGov/c49d872b86fffd37be9f1fd118d89f97 to your computer and use it in GitHub Desktop.
Revisions
-
ProGamerGov created this gist
Feb 12, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ import os from PIL import Image def convert_webp_to_png(directory: str, delete_old_webp_images: bool = False): for root, dirs, files in os.walk(directory): for file in files: if file.endswith(".webp"): filepath = os.path.join(root, file) img = Image.open(filepath) new_filepath = os.path.splitext(filepath)[0] + ".png" img.save(new_filepath, "png", quality=100) if delete_old_webp_images: os.remove(filepath) convert_webp_to_png("/path/to/directory")