World Conquest Chronicles

World Conquest Chronicles

Image Preparer, v1.2.0

The utility for image preparation.

Support optimization of images in JPEG format; add an optimization step via the advpng tool from the AdvanceCOMP project; improve search of images.

Change Log

  • search of images:
    • fix the bug with ignoring files with extensions in uppercase;
    • support Perl-compatible regular expressions (PCREs) in a pattern of image filenames;
  • optimization of images:
    • in PNG format:
    • in JPEG format:

Description

This is the utility for image preparation: resizing of images larger than the specified size and optimization of images in PNG and JPEG formats.

This is a simple script that combines several well-known tools and sets a particular mode for their running. The script also collects some statistics about the results of processing.

I use it to prepare images (screenshots and photos) for my blog.

⚠️ Warning! To avoid damaging the images or significantly degrading their quality, the script should not be run repeatedly on files that have already been processed by it.

Features

  • search of images:
    • recursive search (optionally);
    • filtering by a pattern of image filenames (uses Perl-compatible regular expressions (PCREs));
  • resizing of images larger than the specified size with the Lanczos filter (optionally);
  • optimization of images (optionally):
  • logging of image changes:
    • logging of a change of an image resolution on resizing;
    • logging of a change of an image size:
      • on the following operations:
        • resizing;
        • optimization;
      • logging of a total change of image sizes:
        • total change after all the optimization steps;
        • total change after both resizing and optimization operations;
        • total change for all images together;
      • logging of a saved image size in percent.

Requirements

Installation of the Requirements

On Ubuntu:

$ sudo apt update \
  && sudo apt install imagemagick-6.q16 pngquant optipng advancecomp jpegoptim

Usage

$ image_preparer.bash -v | --version
$ image_preparer.bash -h | --help
$ image_preparer.bash [options] [<path>]

Options:

  • -v, --version — show the version;
  • -h, --help — show the help;
  • -n PATTERN, --name PATTERN — a pattern of image filenames (uses Perl-compatible regular expressions (PCREs); default: (?i)\.(png|jpe?g));
  • -r, --recursive — recursive search of images;
  • -w WIDTH, --width WIDTH — a maximum width of images (default: 640);
  • --no-resize — don't resize images;
  • --no-optimize — don't optimize images.

Arguments:

  • <path> — base path to images (default: .).

Repository

Link: https://github.com/thewizardplusplus/image-preparer/tree/v1.2.0.

Content: code.

License: MIT.

Screenshots

Optimization of images in PNG format