Skip to content
Alexandr edited this page Sep 3, 2020 · 7 revisions

Main

after-parse-options

After parse input user options:

  • DIR_PATH - -p|--path= option (string, not isset by default)
  • PERIOD - -t|--time= option (string, 0 by default)
  • TIME_MARKER - -m|--time-marker= option (string, empty by default)
  • TMP_PATH - -tmp|--tmp-path= option (string, /tmp by default)
  • EXCLUDE_LIST - -e|--exclude= option (string, empty by default)
  • ENABLED_EXTENSIONS - -ext|--extensions= option (string, not isset by default)
  • HELP - -h|--help option (default: 0, 1 for show help message)
  • SHOW_VERSION - -v|--version option (default: 0, 1 for show version)
  • NO_ASK - -q|--quiet option (default: 0, 1 for no ask)
  • LESS - -l|--less option (default: 0, 1 for less output)
  • CHECK_ONLY - -c|--check-only option (default: 0, 1 for check mode)
  • NEW_ONLY - -n|--new-only option (default: 0, 1 for optimize only new images)
  • DEBUG - -d|--debug option (default: 0, 1 for enable debug)
  • UNLOCK - --unlock option (default: 0, 1 for unlock dir in lockfile)

after-init-binary-paths

After define BINARY_PATHS var. Default: /bin /usr/bin /usr/local/bin.

after-init-image-types

After define image types array (IMG_TYPES_ARR).

Default values:

IMG_TYPES_ARR[JPG]="JPG"
IMG_TYPES_ARR[PNG]="PNG"
IMG_TYPES_ARR[GIF]="GIF"

Values of this array are further used to check utilities, install dependencies, and search for images by file extension. You can add new type or delete any.

after-init-tools

After define array with optimizing tools (TOOLS).

Default values:

TOOLS[JPG]="jpegoptim jpegtran djpeg cjpeg"
TOOLS[PNG]="pngcrush optipng pngout advpng"
TOOLS[GIF]="gifsicle"

Listed utilities are checked for exist. You can add tools for new type or modify any.

after-init-img-ext

After init images file extensions.

Default values:

FIND_EXT_ARR[JPG]='JPG JPEG jpg jpeg'
FIND_EXT_ARR[PNG]='PNG png'
FIND_EXT_ARR[GIF]='GIF gif'

Listed file extensions are used for find images. You can add file extensions for new type or modify any.

after-init-vars

After init all vars. You can modify early initialized vars.

after-check-input-data

After check input data. At this step, all data is filtered and brought to the desired form.

Useful vars for change:

  • DIR_PATH - filtered working dir full path
  • TMP_PATH - filtered tmp full path
  • FIND_INCLUDE - custom options for find images
  • TIME_MARKER_FULL_PATH - time marker full path
  • TIME_MARKER_FULL_PATH_DIR - time marker dir full path
  • TIME_MARKER_FULL_PATH_NAME - time marker name
  • TIME_MARKER_ISSET - time marker exist (0 - not exists, 1 - exist)

Dependencies

after-init-deps

After init dependencies.

Default values:

DEPS_DEBIAN="wget autoconf automake libtool make bc"
DEPS_REDHAT="wget autoconf automake libtool make bc"
DEPS_MACOS=""
DEPS_DEBIAN_ARR[JPG]="jpegoptim libjpeg-progs"
DEPS_REDHAT_ARR[JPG]="jpegoptim libjpeg*"
DEPS_MACOS_ARR[JPG]="jpegoptim libjpeg"
DEPS_DEBIAN_ARR[PNG]="pngcrush optipng advancecomp"
DEPS_REDHAT_ARR[PNG]="pngcrush optipng advancecomp"
DEPS_MACOS_ARR[PNG]="pngcrush optipng advancecomp jonof/kenutils/pngout"
DEPS_DEBIAN_ARR[GIF]="gifsicle"
DEPS_REDHAT_ARR[GIF]="gifsicle"
DEPS_MACOS_ARR[GIF]="gifsicle"

This vars used for automatic install dependencies. You can modify main dependencies, add new dependencies for new image type or modify any.

after-init-deps-vars

After init dependencies vars.

Default vars values:

MIN_VERSION_DEBIAN=7
MIN_VERSION_UBUNTU=14
MIN_VERSION_FEDORA=24
MIN_VERSION_RHEL=6
MIN_VERSION_CENTOS=6
MIN_VERSION_MACOS=10
MIN_VERSION_FREEBSD=10

This vars used for automatic install dependencies.

after-check-platform

After check OS platform.

Vars:

  • PLATFORM - OS platform
  • PLATFORM_PKG - OS package format
  • PLATFORM_DISTRIBUTION - OS distribution
  • PLATFORM_ARCH - OS architecture
  • PLATFORM_VERSION - OS version
  • PLATFORM_SUPPORT - support for automatic install dependencies (0 - not supported, 1 - supported)

before-install-deps-linux

Before install dependencies on Linux dists.

before-install-deps-debian

Before install dependencies on DEB-based Linux dists.

after-install-deps-debian

After install dependencies on DEB-based Linux dists.

before-install-deps-redhat

Before install dependencies on RPM-based Linux dists.

before-install-deps-redhat-fedora

Before install dependencies on Fedora Linux.

after-install-deps-redhat-fedora

After install dependencies on Fedora Linux.

before-install-deps-redhat-rhel

Before install dependencies on RHEL.

after-install-deps-redhat-rhel

After install dependencies on RHEL.

before-install-deps-redhat-other

Before install dependencies on RPM-based Linux dists excluding Fedora and RHEL.

after-install-deps-redhat-other

After install dependencies on RPM-based Linux dists excluding Fedora and RHEL.

after-install-deps-redhat

After install dependencies on RPM-based Linux dists.

after-install-deps-linux

After install dependencies on Linux dists.

before-install-deps-macos

Before install dependencies on MacOS.

after-install-deps-macos

After install dependencies on MacOS.

before-install-deps-freebsd

Before install dependencies on FreeBSD.

after-install-deps-freebsd

After install dependencies on FreeBSD.

Main loop

init-loop-vars-after

After define main loop vars (defined before loop).

Vars:

  • IMAGES - list of all found images
  • `IMAGES_TOTAL - count of all found images
  • IMAGES_OPTIMIZED - optimized images counter (default: 0)
  • IMAGES_CURRENT - images counter (default: 0)
  • START_TIME - start time in unixtime

optim-before

Before optimization inside loop for each image.

Useful vars:

  • IMAGE - current image full path
  • OPTIMIZE - optimize current image (default: 1, set 0 to disable build-in optimization)
  • OPTIMIZE_JPG - optimize current JPG image (default: 1, set 0 to disable build-in optimization)
  • OPTIMIZE_PNG - optimize current PNG image (default: 1, set 0 to disable build-in optimization)
  • OPTIMIZE_GIF - optimize current GIF image (default: 1, set 0 to disable build-in optimization)
  • RESTORE_IMAGE_CHECK - compare old and new sizes for restore from backup if new is bigger (default: 1, set 0 to disable check)
  • BACKUP - images backup/restore functionality (default: 1, set 0 to disable)

optim-jpg-before

Before build-in JPG image optimization.

optim-jpg-after

After build-in JPG image optimization.

optim-png-before

Before build-in PNG image optimization.

optim-png-after

After build-in PNG image optimization.

optim-gif-before

Before build-in GIF image optimization.

optim-gif-after

After build-in GIF image optimization.

optim-after

After optimization inside loop for each image.

Total info

total-info-before

Before displaying information after optimization. Useful for display your own info from custom extensions with new functionality.

Useful vars:

  • INPUT - total input images size in bytes
  • OUTPUT - total output images size in bytes
  • SAVED_SIZE - saved images size in bytes
  • IMAGES_OPTIMIZED - count of optimized images
  • IMAGES_TOTAL - count of all images

total-info-time-before

Before displaying information after optimization. Useful for display your own info from custom extensions with new functionality.

Useful vars:

  • INPUT - total input images size in bytes
  • OUTPUT - total output images size in bytes
  • SAVED_SIZE - saved images size in bytes
  • IMAGES_OPTIMIZED - count of optimized images
  • IMAGES_TOTAL - count of all images

total-info-time-before

Before displaying optimization time. Useful for display your own info from custom extensions with new functionality.

Useful vars:

  • INPUT - total input images size in bytes
  • OUTPUT - total output images size in bytes
  • SAVED_SIZE - saved images size in bytes
  • IMAGES_OPTIMIZED - count of optimized images
  • IMAGES_TOTAL - count of all images

total-info-after

After displaying information after optimization. Useful for display your own info from custom extensions with new functionality.

  • INPUT - total input images size in bytes
  • OUTPUT - total output images size in bytes
  • SAVED_SIZE - saved images size in bytes
  • IMAGES_OPTIMIZED - count of optimized images
  • IMAGES_TOTAL - count of all images
  • START_TIME - start time in unixtime
  • END_TIME - end time in unixtime
  • TOTAL_TIME - total spent time in seconds