File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 2
2
set -e
3
3
4
4
# 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
6
11
7
12
# https://pmt.sourceforge.io/pngcrush/
8
13
# On Mac: brew install pngcrush
@@ -11,4 +16,9 @@ python3 scripts/thumbnail-images.py
11
16
# -ow Overwrite
12
17
# -brute Use brute-force: try 176 different methods
13
18
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 3
3
"""
4
4
Thumbnail images to a maximum of 320px wide and 160px high
5
5
"""
6
+ import argparse
6
7
import glob
7
8
8
9
from PIL import Image # pip install pillow
9
10
10
11
max_size = 320 , 160
11
12
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 ):
13
21
im = Image .open (infile )
14
22
if im .width <= max_size [0 ] and im .height <= max_size [1 ]:
15
23
continue
You can’t perform that action at this time.
0 commit comments