File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 22set -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
Original file line number Diff line number Diff line change 33"""
44Thumbnail images to a maximum of 320px wide and 160px high
55"""
6+ import argparse
67import glob
78
89from PIL import Image # pip install pillow
910
1011max_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
You can’t perform that action at this time.
0 commit comments