File last modified on August 18, 2022

Image Compression

In an ePub img directory all images, excluding the Cover, should be in a PNG format. To make sure we stay below retail channel file size guidelines and our ePubs operate smoothly when customers view our titles please use OptiPNG to compress PNG files.

Open Terminal.app which can be found in Applications > Utilities > Terminal.app.

Verify Homebrew exists with brew --version and it should output Homebrew X.X.X.

Enter brew list and look to see if OptiPNG exists. If not run brew install optipng to install OptiPNG in the Terminal. Another way to test for OptiPNG in the Terminal is to run man optipng. If you are viewing the manual of OptiPNG you can exit out by using the q button.

Point the Terminal to the directory of images by typing cd then dragging and dropping the folder into the Terminal, example:

bash
1
cd /Users/<username>/path/to/img

Verify images exist in the img directory:

bash
1
ls -l

If PNG images are returned in the terminal run OptiPNG:

bash
1
optipng -o7 *.png

If you want an image's before and after for comparison run:

bash
1
optipng -k -o7 *.png

Shortcut

This is a shortcut approach to help users use OptiPNG through a shortcut that can be an entered command executed in the Terminal.

Open Termnial.app and type the command:

bash
1
cd && nano ~/.bash_profile

Add a comment line to indicate what is going on/reference (always a good practice to leave a comment), example:

bash
1
# PNG Shortcut

Add alias pngcompress='optipng -o7 *.png' (should be on a new line), example:

bash
1
# PNG Shortcut
2
alias pngcompress='optipng -o7 *.png'

Exit the .bash_profile using control+X and reboot the Terminal:

bash
1
. .bash_profile ## notice the two periods

Navigate to the folder where PNGs exist that need compression, example:

If images existed in a directory name Test on your Desktop:

bash
1
cd Desktop/Test

Type the command pngcompress and you should see compression happening in the Terminal.

ON THIS PAGE
Last build: Thursday, 08/18/2022, 01:01:08 AM