Skip to content

Commit 52011e5

Browse files
authored
Merge pull request #208 from hugovk/master
Add param to only squash single image
2 parents 8155bf2 + 796395f commit 52011e5

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Diff for: scripts/squash-images.sh

+12-2
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 --file $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

Diff for: scripts/thumbnail-images.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
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

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

0 commit comments

Comments
 (0)