Flaca v3.1.9
License: WTFPL
Released: 2024-10-17

Flaca

Flaca is a CLI tool for x86-64 Linux machines that simplifies the task of maximally, losslessly compressing JPEG and PNG images for use in production web environments.

It prioritizes compression over speed or resource modesty, and runs best on systems with multiple CPUs. There are only so many ways to be a JPEG, but calculating the optimal construction for a PNG can take a lot of work!

Compression is mainly achieved through the removal of metadata and optimization of pixel tables. Under the hood, Flaca leverages the jpegtran functionality from MozJPEG for JPEG images, and a combination of Oxipng and Zopflipng for PNG images.

Metadata

For web images, metadata is just so much wasted bandwidth. Stock photos in particular can be bloated 50% or more with embedded keywords and descriptions that browsers make zero use of. Removing that data — particularly at scale — leads to both lower hosting costs for site operators and faster page loads for visitors.

And it helps close the digital divide.

But in other contexts, metadata may matter.

As a general rule, you should not try to feed your entire personal media library or raw print/design assets to Flaca or it may eat something important.

Installation

Debian and Ubuntu users can just grab the pre-built .deb package from the latest release.

This application is written in Rust and can alternatively be built from source using Cargo:

# Clone the source.
git clone --recurse-submodules https://github.com/Blobfolio/flaca.git

# Go to it.
cd flaca

# Build as usual. Specify additional flags as desired.
cargo build \
    --bin flaca \
    --release

(This should work under other 64-bit Unix environments too, like MacOS.)

In addition to up-to-date Rust/Cargo, you'll also need gcc, make, nasm, a C++ compiler, and the dev libraries for libjpeg and libpng.

The above list may not be exhaustive, though. If you find you need anything else, please open a ticket so this list can be updated!

Usage

It's easy. Just run flaca [FLAGS] [OPTIONS] <PATH(S)>….

The following flags and options are available:

Short Long Value Description
-h --help Print help information and exit.
-l --list <FILE> Read (absolute) image and/or directory paths from this text file, one entry per line.
--no-jpeg Skip JPEG images.
--no-png Skip PNG Images.
-p --progress Show progress while minifying.
-V --version Print version information and exit.

You can feed it any number of file or directory paths in one go, and/or toss it a text file using the -l option. Directories are recursively searched.

Flaca can cross filesystem and user boundaries, provided the user running the program has the relevant read/write access. (Not that you should run it as root, but if you did, images would still be owned by www-data or whatever after compression.)

Some quick examples:

# Compress one file.
flaca /path/to/image.jpg

# Tackle a whole folder at once with a nice progress bar:
flaca -p /path/to/assets

# Tackle a whole folder, but only look for JPEG images.
flaca -p --no-png /path/to/assets

# Or load it up with a lot of places separately:
flaca /path/to/assets /path/to/favicon.png …