-
-
Notifications
You must be signed in to change notification settings - Fork 20
Hooks
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 define BINARY_PATHS
var. Default: /bin /usr/bin /usr/local/bin
.
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 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 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 all vars. You can modify early initialized vars.
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)
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 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 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 dependencies on Linux dists.
Before install dependencies on DEB-based Linux dists.
After install dependencies on DEB-based Linux dists.
Before install dependencies on RPM-based Linux dists.
Before install dependencies on Fedora Linux.
After install dependencies on Fedora Linux.
Before install dependencies on RHEL.
After install dependencies on RHEL.
Before install dependencies on RPM-based Linux dists excluding Fedora and RHEL.
After install dependencies on RPM-based Linux dists excluding Fedora and RHEL.
After install dependencies on RPM-based Linux dists.
After install dependencies on Linux dists.
Before install dependencies on MacOS.
After install dependencies on MacOS.
Before install dependencies on FreeBSD.
After install dependencies on FreeBSD.
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
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)
Before build-in JPG image optimization.
After build-in JPG image optimization.
Before build-in PNG image optimization.
After build-in PNG image optimization.
Before build-in GIF image optimization.
After build-in GIF image optimization.
After optimization inside loop for each image.
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
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
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
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