Skip to content

Instantly share code, notes, and snippets.

@deeperlearner
Created November 14, 2020 08:57
Show Gist options
  • Save deeperlearner/9eb70b462df792b5c311a51497bd2399 to your computer and use it in GitHub Desktop.
Save deeperlearner/9eb70b462df792b5c311a51497bd2399 to your computer and use it in GitHub Desktop.
photo_resizer.py
import sys
from pathlib import Path
from PIL import Image
# usage: python3 photo_resizer.py img.png
img_file = sys.argv[1]
path = Path(img_file)
assert path.parent == Path(), "The image must in the same directory with photo_resizer.py"
img = Image.open(img_file)
img = img.resize((img.size[0]//2, img.size[1]//2))
img.save("LR_" + img_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment