Skip to content

Commit 49e5125

Browse files
committed
Add scripts to thumbnail and compress images
1 parent 97e13ef commit 49e5125

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

scripts/squash-images.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
#https://pngquant.org/
4+
# On Mac: brew install pngquant
5+
6+
# Options:
7+
# --ext .png Output to same filename, don't append anything else
8+
# --force Overwrite existing output files
9+
# --speed 1 Slow speed, best quality
10+
# --strip Remove optional metadata
11+
12+
pngquant --ext .png --force --speed 1 --strip assets/*.png img/*.png

scripts/thumbnail-images.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python3
2+
# encoding: utf-8
3+
"""
4+
Thumbnail images to a maximum of 160px wide and 80px high
5+
"""
6+
import glob
7+
8+
from PIL import Image # pip install pillow
9+
10+
max_size = 160, 80
11+
12+
for infile in glob.glob("assets/*.png"):
13+
im = Image.open(infile)
14+
im.thumbnail(max_size)
15+
im.save(infile)

0 commit comments

Comments
 (0)