Skip to content

Commit dd63956

Browse files
committed
Add param to only squash single image
1 parent 8155bf2 commit dd63956

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

scripts/squash-images.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
set -e
33

44
# pip install pillow
5-
python3 scripts/thumbnail-images.py
5+
if [ ! -z $1 ]
6+
then
7+
python3 scripts/thumbnail-images.py --inspec $1
8+
else
9+
python3 scripts/thumbnail-images.py
10+
fi
611

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

14-
find . -iname '*.png' -exec pngcrush -ow -brute {} \;
19+
if [ ! -z $1 ]
20+
then
21+
pngcrush -ow -brute $1
22+
else
23+
find . -iname '*.png' -exec pngcrush -ow -brute {} \;
24+
fi

scripts/thumbnail-images.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@
33
"""
44
Thumbnail images to a maximum of 320px wide and 160px high
55
"""
6+
import argparse
67
import glob
78

89
from PIL import Image # pip install pillow
910

1011
max_size = 320, 160
1112

13+
parser = argparse.ArgumentParser(
14+
description="Thumbnail images to a maximum size",
15+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
16+
)
17+
parser.add_argument("--inspec", default="assets/*.png", help="Input file specification")
18+
args = parser.parse_args()
19+
1220
for infile in glob.glob("assets/*.png"):
1321
im = Image.open(infile)
1422
if im.width <= max_size[0] and im.height <= max_size[1]:

0 commit comments

Comments
 (0)