diff --git a/scripts/squash-images.sh b/scripts/squash-images.sh index 52ddc16..206e3d9 100755 --- a/scripts/squash-images.sh +++ b/scripts/squash-images.sh @@ -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 @@ -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 diff --git a/scripts/thumbnail-images.py b/scripts/thumbnail-images.py index d00bb00..dedd89a 100644 --- a/scripts/thumbnail-images.py +++ b/scripts/thumbnail-images.py @@ -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