Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions scripts/squash-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
set -e

# pip install pillow
python3 scripts/thumbnail-images.py
if [ ! -z $1 ]
then
python3 scripts/thumbnail-images.py --file $1
else
python3 scripts/thumbnail-images.py
fi

# https://pmt.sourceforge.io/pngcrush/
# On Mac: brew install pngcrush
Expand All @@ -11,4 +16,9 @@ python3 scripts/thumbnail-images.py
# -ow Overwrite
# -brute Use brute-force: try 176 different methods

find . -iname '*.png' -exec pngcrush -ow -brute {} \;
if [ ! -z $1 ]
then
pngcrush -ow -brute $1
else
find . -iname '*.png' -exec pngcrush -ow -brute {} \;
fi
10 changes: 9 additions & 1 deletion scripts/thumbnail-images.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
"""
Thumbnail images to a maximum of 320px wide and 160px high
"""
import argparse
import glob

from PIL import Image # pip install pillow

max_size = 320, 160

for infile in glob.glob("assets/*.png"):
parser = argparse.ArgumentParser(
description="Thumbnail images to a maximum size",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("--file", default="assets/*.png", help="Input file specification")
args = parser.parse_args()

for infile in glob.glob(args.file):
im = Image.open(infile)
if im.width <= max_size[0] and im.height <= max_size[1]:
continue
Expand Down