OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # The optimization code is based on pngslim (http://goo.gl/a0XHg) | 6 # The optimization code is based on pngslim (http://goo.gl/a0XHg) |
7 # and executes a similar pipleline to optimize the png file size. | 7 # and executes a similar pipleline to optimize the png file size. |
8 # The steps that require pngoptimizercl/pngrewrite/deflopt are omitted, | 8 # The steps that require pngoptimizercl/pngrewrite/deflopt are omitted, |
9 # but this runs all other processes, including: | 9 # but this runs all other processes, including: |
10 # 1) various color-dependent optimizations using optipng. | 10 # 1) various color-dependent optimizations using optipng. |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 OPTIMIZE_LEVEL=$OPTARG | 384 OPTIMIZE_LEVEL=$OPTARG |
385 [ "$1" == "-o" ] && shift | 385 [ "$1" == "-o" ] && shift |
386 shift;; | 386 shift;; |
387 [h?]) | 387 [h?]) |
388 show_help;; | 388 show_help;; |
389 esac | 389 esac |
390 done | 390 done |
391 | 391 |
392 # Make sure we have all necessary commands installed. | 392 # Make sure we have all necessary commands installed. |
393 install_if_not_installed pngcrush pngcrush | 393 install_if_not_installed pngcrush pngcrush |
394 if [ $OPTIMIZE_LEVEL == 2 ]; then | 394 if [ $OPTIMIZE_LEVEL -ge 1 ]; then |
395 install_if_not_installed optipng optipng | 395 install_if_not_installed optipng optipng |
396 | 396 |
397 if $using_cygwin ; then | 397 if $using_cygwin ; then |
398 fail_if_not_installed advdef "http://advancemame.sourceforge.net/comp-readme
.html" | 398 fail_if_not_installed advdef "http://advancemame.sourceforge.net/comp-readme
.html" |
399 else | 399 else |
400 install_if_not_installed advdef advancecomp | 400 install_if_not_installed advdef advancecomp |
401 fi | 401 fi |
402 | 402 |
403 if $using_cygwin ; then | 403 if $using_cygwin ; then |
404 pngout_url="http://www.advsys.net/ken/utils.htm" | 404 pngout_url="http://www.advsys.net/ken/utils.htm" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 "that could be optimized" \ | 437 "that could be optimized" \ |
438 "in $(date -u -d @$SECONDS +%T)s" | 438 "in $(date -u -d @$SECONDS +%T)s" |
439 else | 439 else |
440 let diff=$TOTAL_OLD_BYTES-$TOTAL_NEW_BYTES | 440 let diff=$TOTAL_OLD_BYTES-$TOTAL_NEW_BYTES |
441 let percent=$diff*100/$TOTAL_OLD_BYTES | 441 let percent=$diff*100/$TOTAL_OLD_BYTES |
442 echo "Processed $PROCESSED_FILE files (out of $TOTAL_FILE files)" \ | 442 echo "Processed $PROCESSED_FILE files (out of $TOTAL_FILE files)" \ |
443 "in $(date -u -d @$SECONDS +%T)s" | 443 "in $(date -u -d @$SECONDS +%T)s" |
444 echo "Result : $TOTAL_OLD_BYTES => $TOTAL_NEW_BYTES bytes" \ | 444 echo "Result : $TOTAL_OLD_BYTES => $TOTAL_NEW_BYTES bytes" \ |
445 "($diff bytes : $percent %)" | 445 "($diff bytes : $percent %)" |
446 fi | 446 fi |
OLD | NEW |