Skip to content

Instantly share code, notes, and snippets.

@yuhangch
Last active December 24, 2020 07:41
Show Gist options
  • Save yuhangch/582615c6c1f90ce10748d4a2d33cd420 to your computer and use it in GitHub Desktop.
Save yuhangch/582615c6c1f90ce10748d4a2d33cd420 to your computer and use it in GitHub Desktop.
Tiny PNG & tinify demo
import os
import tinify
tinify.key = "your key"
root = "./images"
dst_path = "./images-compress"
for origin, _, files in os.walk(root, topdown=False):
for name in files:
input_file = origin + os.sep + name
dst_file = dst_path + os.sep + name
source = tinify.from_file(input_file)
source.to_file(dst_file)
print(input_file, dst_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment