File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env zsh
2+
3+ # Capture script name
4+ SCRIPT_NAME=$0
5+
6+ # Variables
7+ ICONS_DIR=" icons"
8+
9+ # Function to show help
10+ show_help () {
11+ echo " Usage: $SCRIPT_NAME [options]"
12+ echo " Options:"
13+ echo " -h, --help Show this help message"
14+ }
15+
16+ # Parse options
17+ while [[ " $# " -gt 0 ]]; do
18+ case $1 in
19+ -h|--help) show_help; exit 0;;
20+ * ) echo " Unknown option: $1 " ; show_help; exit 1;;
21+ esac
22+ shift
23+ done
24+
25+ # Check if oxipng is installed
26+ if ! command -v oxipng & > /dev/null; then
27+ echo " oxipng is not installed."
28+ read " response?Would you like to install it with Homebrew? (y/n) "
29+ if [[ " $response " == " y" || " $response " == " Y" ]]; then
30+ if command -v brew & > /dev/null; then
31+ echo " Installing oxipng with Homebrew..."
32+ brew install oxipng
33+ else
34+ echo " Homebrew is not installed. Please install Homebrew first: https://brew.sh/"
35+ exit 1
36+ fi
37+ else
38+ echo " Please install oxipng with Homebrew: brew install oxipng"
39+ exit 1
40+ fi
41+ fi
42+
43+ # Optimize PNG files in the icons directory
44+ if [ -d $ICONS_DIR ]; then
45+ echo " Optimizing PNG files in the $ICONS_DIR directory..."
46+ oxipng -o max --dir $ICONS_DIR --alpha $ICONS_DIR /* .png
47+ echo " Optimization completed."
48+ else
49+ echo " Icons directory does not exist: $ICONS_DIR "
50+ exit 1
51+ fi
You can’t perform that action at this time.
0 commit comments