Skip to content

Commit dfaa83e

Browse files
authored
Merge pull request #2 from NathanJPlummer/addArguments
Add arguments/ Update README
2 parents 16a4d7d + 29a4d8e commit dfaa83e

File tree

2 files changed

+73
-47
lines changed

2 files changed

+73
-47
lines changed

README.md

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,45 @@ By design, Guetzling will overwrite and/or delete your original files. If you w
1111
## Usage
1212
1. Simply `cd` to the parent directory of your choice, and `guetzling`. ***Voilà!***
1313

14-
## Adjustable Options
15-
16-
By opening the script in a text editor, you can adjust certain variables to change the output of Guetzling.
17-
18-
### JPG
19-
20-
Enable/Disable re-compression of JPG and JPEG files using Guetzling.
21-
22-
#Recompress JPG Images
23-
#Set to false to disable
24-
JPG=true
25-
26-
### PNG
27-
28-
Enable/Disable the conversion of PNG to JPG using Guetzling.
29-
30-
#Convert PNG Images
31-
#Set to false to disable
32-
#PNGS WILL BE DELETED AFTER CONVERSION
33-
PNG=true
34-
35-
### QUALITY
36-
37-
Change Guetzling/Guetzli Quality Level.
38-
39-
#Set Quality level
40-
#Default = 95
41-
#Max = 100
42-
#Min = 84
43-
QUALITY=95
14+
## Adjustable Parameters
15+
16+
By Default, Guetzling uses the following options:
17+
18+
- JPGs are re-compressed and overwritten
19+
- PNGs are converted to JPG and the originals are deleted
20+
- Quality Level is for Guetzli is set to 95
21+
22+
You can adjust these options using bash arguments:
23+
24+
1. Quality for JPG re-compression.
25+
- Requires a value between 84 and 100 for Guetzli is designed to fail
26+
- Default value is the same as Guetzli: 95
27+
28+
2. Quality for PNG conversion.
29+
- Requires a value between 84 and 100 for Guetzli is designed to fail
30+
- Default value is the same as Guetzli: 95
31+
32+
3. Compress JPGs
33+
- Set to "false" and Guetzliing will ignore JPG/JPEG files, compressing only PNGS.
34+
35+
4. Compress PNGs
36+
- Set to "false" and Guetzling will ignore PNG files, compressing only JPGS
37+
38+
5. Delete PNG
39+
- Set to "false" and Guetzling will keep the copy of any original PNGs in your folder
40+
41+
42+
## Example Usage
43+
44+
Replace all files at quality 95:
45+
46+
./guetzling
47+
48+
Convert JPGs at 95, PNGs at 84, and keep your original PNG files:
49+
50+
./guetzling 95 84 true true false
51+
52+
Convert only JPGs at Quality Level 97:
53+
54+
./guetzling 97 95 true false
55+

guetzling

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
#!/bin/bash
22

3+
#Set Quality level for JPG recompression
4+
#Default = 95
5+
#Max = 100
6+
#Min = 84
7+
QUALITY_JPG=${1:-95}
8+
9+
#Set Quality level
10+
#Default = 95
11+
#Max = 100
12+
#Min = 84
13+
QUALITY_PNG=${2:-95}
14+
315
#Recompress JPG Images
416
#Set to false to disable
5-
JPG=true
17+
JPG=${3:-true}
618

719
#Convert PNG Images
820
#Set to false to disable
9-
#PNGS WILL BE DELETED AFTER CONVERSION
10-
PNG=true
21+
#PNGS WILL BE DELETED AFTER CONVERSION UNLESS OTHERWISE SPECIFIED
22+
PNG=${4:-true}
1123

12-
#Set Quality level
13-
#Default = 95
14-
#Max = 100
15-
#Min = 84
16-
QUALITY=95
24+
#Remove original PNGS after conversion to JPG
25+
PNG_DELETE=${5:-true}
1726

1827
IFS=$'\n';
1928
FOLDER=$(pwd)
@@ -23,8 +32,8 @@ if [ $JPG = true ];
2332
for f in $(find "$FOLDER" -name '*.jpg')
2433
#for f in $1/*.jpg
2534
do
26-
echo "Guetzling file - $f..."
27-
guetzli --quality "$QUALITY" "$f" "$f"
35+
echo "Guetzling file - $f at level '$QUALITY_JPG'..."
36+
guetzli --quality "$QUALITY_JPG" "$f" "$f"
2837
echo "Done."
2938
done
3039
fi
@@ -34,9 +43,9 @@ if [ $JPG = true ];
3443
for f in $(find "$FOLDER" -name '*.jpeg')
3544
#for f in $1/*.jpeg
3645
do
37-
echo "Guetzling file - $f..."
38-
guetzli --quality "$QUALITY" "$f" "$f"
39-
echo "Done."
46+
echo "Guetzling file - $f at level '$QUALITY_JPG'..."
47+
guetzli --quality "$QUALITY_JPG" "$f" "$f"
48+
echo "Done."
4049
done
4150
fi
4251

@@ -45,9 +54,14 @@ if [ $PNG = true ];
4554
for f in $(find "$FOLDER" -name '*.png')
4655
#for f in $1/*.png
4756
do
48-
echo "Guetzling file - $f..."
49-
guetzli --quality "$QUALITY" "$f" "${f%.png}.jpg"
50-
rm "$f"
51-
echo "Done."
57+
echo "Guetzling file - $f at level '$QUALITY_PNG' ..."
58+
guetzli --quality "$QUALITY_PNG" "$f" "${f%.png}.jpg"
59+
60+
if [ $PNG_DELETE = true ];
61+
then
62+
rm "$f"
63+
fi
64+
65+
echo "Done."
5266
done
5367
fi

0 commit comments

Comments
 (0)