Skip to content

Commit

Permalink
Merge pull request #2 from NathanJPlummer/addArguments
Browse files Browse the repository at this point in the history
Add arguments/ Update README
  • Loading branch information
lejacobroy authored May 2, 2017
2 parents 16a4d7d + 29a4d8e commit dfaa83e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 47 deletions.
72 changes: 42 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,45 @@ By design, Guetzling will overwrite and/or delete your original files. If you w
## Usage
1. Simply `cd` to the parent directory of your choice, and `guetzling`. ***Voilà!***

## Adjustable Options

By opening the script in a text editor, you can adjust certain variables to change the output of Guetzling.

### JPG

Enable/Disable re-compression of JPG and JPEG files using Guetzling.

#Recompress JPG Images
#Set to false to disable
JPG=true

### PNG

Enable/Disable the conversion of PNG to JPG using Guetzling.

#Convert PNG Images
#Set to false to disable
#PNGS WILL BE DELETED AFTER CONVERSION
PNG=true

### QUALITY

Change Guetzling/Guetzli Quality Level.

#Set Quality level
#Default = 95
#Max = 100
#Min = 84
QUALITY=95
## Adjustable Parameters

By Default, Guetzling uses the following options:

- JPGs are re-compressed and overwritten
- PNGs are converted to JPG and the originals are deleted
- Quality Level is for Guetzli is set to 95

You can adjust these options using bash arguments:

1. Quality for JPG re-compression.
- Requires a value between 84 and 100 for Guetzli is designed to fail
- Default value is the same as Guetzli: 95

2. Quality for PNG conversion.
- Requires a value between 84 and 100 for Guetzli is designed to fail
- Default value is the same as Guetzli: 95

3. Compress JPGs
- Set to "false" and Guetzliing will ignore JPG/JPEG files, compressing only PNGS.

4. Compress PNGs
- Set to "false" and Guetzling will ignore PNG files, compressing only JPGS

5. Delete PNG
- Set to "false" and Guetzling will keep the copy of any original PNGs in your folder


## Example Usage

Replace all files at quality 95:

./guetzling

Convert JPGs at 95, PNGs at 84, and keep your original PNG files:

./guetzling 95 84 true true false

Convert only JPGs at Quality Level 97:

./guetzling 97 95 true false

48 changes: 31 additions & 17 deletions guetzling
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
#!/bin/bash

#Set Quality level for JPG recompression
#Default = 95
#Max = 100
#Min = 84
QUALITY_JPG=${1:-95}

#Set Quality level
#Default = 95
#Max = 100
#Min = 84
QUALITY_PNG=${2:-95}

#Recompress JPG Images
#Set to false to disable
JPG=true
JPG=${3:-true}

#Convert PNG Images
#Set to false to disable
#PNGS WILL BE DELETED AFTER CONVERSION
PNG=true
#PNGS WILL BE DELETED AFTER CONVERSION UNLESS OTHERWISE SPECIFIED
PNG=${4:-true}

#Set Quality level
#Default = 95
#Max = 100
#Min = 84
QUALITY=95
#Remove original PNGS after conversion to JPG
PNG_DELETE=${5:-true}

IFS=$'\n';
FOLDER=$(pwd)
Expand All @@ -23,8 +32,8 @@ if [ $JPG = true ];
for f in $(find "$FOLDER" -name '*.jpg')
#for f in $1/*.jpg
do
echo "Guetzling file - $f..."
guetzli --quality "$QUALITY" "$f" "$f"
echo "Guetzling file - $f at level '$QUALITY_JPG'..."
guetzli --quality "$QUALITY_JPG" "$f" "$f"
echo "Done."
done
fi
Expand All @@ -34,9 +43,9 @@ if [ $JPG = true ];
for f in $(find "$FOLDER" -name '*.jpeg')
#for f in $1/*.jpeg
do
echo "Guetzling file - $f..."
guetzli --quality "$QUALITY" "$f" "$f"
echo "Done."
echo "Guetzling file - $f at level '$QUALITY_JPG'..."
guetzli --quality "$QUALITY_JPG" "$f" "$f"
echo "Done."
done
fi

Expand All @@ -45,9 +54,14 @@ if [ $PNG = true ];
for f in $(find "$FOLDER" -name '*.png')
#for f in $1/*.png
do
echo "Guetzling file - $f..."
guetzli --quality "$QUALITY" "$f" "${f%.png}.jpg"
rm "$f"
echo "Done."
echo "Guetzling file - $f at level '$QUALITY_PNG' ..."
guetzli --quality "$QUALITY_PNG" "$f" "${f%.png}.jpg"

if [ $PNG_DELETE = true ];
then
rm "$f"
fi

echo "Done."
done
fi

0 comments on commit dfaa83e

Please sign in to comment.