Created
November 29, 2019 08:12
-
-
Save ariesduanmu/42500f4180454f6c9f4ab71fa2ebebc8 to your computer and use it in GitHub Desktop.
compress image using tinypng(https://tinypng.com/)
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 characters
| import os | |
| import tinify | |
| from PIL import Image | |
| tinify.key = "THIS IS MY KEY" | |
| orginal_path = r"ORIGINAL_DIR" | |
| compressed_path = r"COMPRESSED_DIR" | |
| for image_name in os.listdir(orginal_path): | |
| image_path = os.path.join(orginal_path, image_name) | |
| tiny_image_path = os.path.join(compressed_path, image_name) | |
| tinify.from_file(image_path).to_file(tiny_image_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment