This commit is contained in:
Laurent Destailleur 2014-11-30 15:24:39 +01:00
parent d39dbe66c8
commit e395fd8096
11 changed files with 91 additions and 67 deletions

View File

@ -37,7 +37,8 @@ optimize_image()
max_input_size=$(expr $max_input_size + $input_file_size) max_input_size=$(expr $max_input_size + $input_file_size)
if [ "${1##*.}" = "png" ]; then if [ "${1##*.}" = "png" ]; then
optipng -o1 -clobber -quiet $1 -out $2.firstpass #optipng -o1 -clobber -quiet $1 -out $2.firstpass
optipng -o1 -quiet $1 -out $2.firstpass
pngcrush -q -rem alla -reduce $2.firstpass $2 >/dev/null pngcrush -q -rem alla -reduce $2.firstpass $2 >/dev/null
rm -fr $2.firstpass rm -fr $2.firstpass
fi fi
@ -67,6 +68,25 @@ get_max_file_length()
main() main()
{ {
test=`type pngcrush >/dev/null 2>&1`
result=$?
if [ "x$result" == "x1" ]; then
echo "Tool pngcrush not found" && exit
fi
test=`type optipng >/dev/null 2>&1`
result=$?
if [ "x$result" == "x1" ]; then
echo "Tool optipng not found" && exit
fi
test=`type jpegtran >/dev/null 2>&1`
result=$?
if [ "x$result" == "x1" ]; then
echo "Tool jpegtran not found" && exit
fi
# If $INPUT is empty, then we use current directory # If $INPUT is empty, then we use current directory
if [[ "$INPUT" == "" ]]; then if [[ "$INPUT" == "" ]]; then
INPUT=$(pwd) INPUT=$(pwd)
@ -81,6 +101,8 @@ main()
OUTPUT='/tmp/optimize' OUTPUT='/tmp/optimize'
fi fi
echo "Mode is $INPLACE (0=Images are replaced, 1=New images are stored into $OUTPUT)"
# We create the output directory # We create the output directory
mkdir -p $OUTPUT mkdir -p $OUTPUT
@ -96,6 +118,7 @@ main()
# Search of all jpg/jpeg/png in $INPUT # Search of all jpg/jpeg/png in $INPUT
# We remove images from $OUTPUT if $OUTPUT is a subdirectory of $INPUT # We remove images from $OUTPUT if $OUTPUT is a subdirectory of $INPUT
echo "Scan $INPUT to find images"
IMAGES=$(find $INPUT -regextype posix-extended -regex '.*\.(jpg|jpeg|png)' | grep -v $OUTPUT) IMAGES=$(find $INPUT -regextype posix-extended -regex '.*\.(jpg|jpeg|png)' | grep -v $OUTPUT)
if [ "$QUIET" == "0" ]; then if [ "$QUIET" == "0" ]; then
@ -103,6 +126,7 @@ main()
echo echo
fi fi
for CURRENT_IMAGE in $IMAGES; do for CURRENT_IMAGE in $IMAGES; do
echo "Process $CURRENT_IMAGE"
filename=$(basename $CURRENT_IMAGE) filename=$(basename $CURRENT_IMAGE)
if [ "$QUIET" == "0" ]; then if [ "$QUIET" == "0" ]; then
printf '%s ' "$filename" printf '%s ' "$filename"

View File

0
htdocs/install/upgrade.php Executable file → Normal file
View File

0
htdocs/install/upgrade2.php Executable file → Normal file
View File