-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimageoptimizer.bash
More file actions
43 lines (33 loc) · 1.22 KB
/
Copy pathimageoptimizer.bash
File metadata and controls
43 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#################################################################
# Copyright (C) 2016 Ti Dimensie AG
# Webiste: https://tdwebservices.com/
# E-Mail: info@tdwebservices.com
#
# This file is part of TDWS Image Optimization.
#
# This file is subject to the terms and conditions defined in
# file 'LICENSE.txt', which is part of this source code package.
#################################################################
OPTIPNG_BIN="/usr/bin/optipng"
JPEGOPTIM_BIN="/usr/bin/jpegoptim"
LOG_DIR="/root"
if [[ $# -eq 0 ]] ; then
echo 'need path';
exit 1;
fi
PATH=$1
if ! [ -x "$(command -v $OPTIPNG_BIN)" ]; then
echo 'optipng not installed exiting..' >&2;
exit 1;
fi
if ! [ -x "$(command -v $JPEGOPTIM_BIN)" ]; then
echo 'jpegoptim not installed exiting..' >&2;
exit 1;
fi
echo `/bin/date` >> ${LOG_DIR}/optipng.log
/usr/bin/find ${PATH} -iname '*.png' -mtime -1 -exec ${OPTIPNG_BIN} -o5 -preserve {} \; >> ${LOG_DIR}/optipng.log
echo "---Done---" >> ${LOG_DIR}/optipng.log
echo `/bin/date` >> ${LOG_DIR}/jpegoptim.log
/usr/bin/find ${PATH} -iname '*.jpg' -mtime -1 -exec ${JPEGOPTIM_BIN} --preserve --strip-all --totals {} \; >> ${LOG_DIR}/jpegoptim.log
echo "---Done---" >> ${LOG_DIR}/jpegoptim.log