Skip to content

Commit

Permalink
Merge pull request #1 from NathanJPlummer/master
Browse files Browse the repository at this point in the history
Add adjustable options and update README.
  • Loading branch information
lejacobroy authored May 2, 2017
2 parents 712c992 + b6ab25d commit 16a4d7d
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 12 deletions.
43 changes: 38 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
# Introduction

Guetzling is a simple script for macOS and Linux written in Bash, to automate (recursively finding files) the compression of jpegs using the Guetzli algorithm.
Guetzling is a simple script for macOS and Linux written in Bash to automate (recursively finding files) the compression of JPGs and PNGs using the Guetzli algorithm.

## Install
1. Install [Guetzli](https://github.com/google/guetzli), and copy it to an executable folder (`/usr/bin` for example), if it's not already there.
2. Copy Guetzling, copy it to `/usr/bin` or something like that.
By design, Guetzling will overwrite and/or delete your original files. If you want to keep your originals, make a backup of your folder before using Guetzling.

## Install Guetzli
1. Install [Guetzli](https://github.com/google/guetzli), via the directions provided at the link.
2. Copy Guetzling, copy it to `/usr/bin`.

## Usage
1. Simply `cd` to the parent directory of your choice, and `guetzling`. ***Voilà!***
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
57 changes: 50 additions & 7 deletions guetzling
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
#!/bin/bash

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

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

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

IFS=$'\n';
FOLDER=$(pwd)
for f in $(find "$FOLDER" -name '*.jpg')
#for f in $1/*.jpg
do
echo "Guetzling file - $f..."
guetzli -quality 95 "$f" "$f"
echo "Done."
done

if [ $JPG = true ];
then
for f in $(find "$FOLDER" -name '*.jpg')
#for f in $1/*.jpg
do
echo "Guetzling file - $f..."
guetzli --quality "$QUALITY" "$f" "$f"
echo "Done."
done
fi

if [ $JPG = true ];
then
for f in $(find "$FOLDER" -name '*.jpeg')
#for f in $1/*.jpeg
do
echo "Guetzling file - $f..."
guetzli --quality "$QUALITY" "$f" "$f"
echo "Done."
done
fi

if [ $PNG = true ];
then
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."
done
fi

0 comments on commit 16a4d7d

Please sign in to comment.