OLD | NEW |
1 #!/bin/bash -i | 1 #!/bin/bash -i |
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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 which $program > /dev/null 2>&1 | 377 which $program > /dev/null 2>&1 |
378 if [ $? != 0 ]; then | 378 if [ $? != 0 ]; then |
379 echo "Couldn't find $program. Please download and install it from $url ." | 379 echo "Couldn't find $program. Please download and install it from $url ." |
380 exit 1 | 380 exit 1 |
381 fi | 381 fi |
382 } | 382 } |
383 | 383 |
384 # Check pngcrush version and exit if the version is in bad range. | 384 # Check pngcrush version and exit if the version is in bad range. |
385 # See crbug.com/404893. | 385 # See crbug.com/404893. |
386 function exit_if_bad_pngcrush_version { | 386 function exit_if_bad_pngcrush_version { |
387 local version=$(pngcrush -v | awk "/pngcrush 1.7./ {print \$3}") | 387 local version=$(pngcrush -v 2>&1 | awk "/pngcrush 1.7./ {print \$3}") |
388 local version_num=$(echo $version | sed "s/\.//g") | 388 local version_num=$(echo $version | sed "s/\.//g") |
389 if [[ (1748 -lt $version_num && $version_num -lt 1773) ]] ; then | 389 if [[ (1748 -lt $version_num && $version_num -lt 1773) ]] ; then |
390 echo "Your pngcrush ($version) has a bug that exists from " \ | 390 echo "Your pngcrush ($version) has a bug that exists from " \ |
391 "1.7.49 to 1.7.72 (see crbug.com/404893 for details)." | 391 "1.7.49 to 1.7.72 (see crbug.com/404893 for details)." |
392 echo "Please upgrade pngcrush and try again" | 392 echo "Please upgrade pngcrush and try again" |
393 exit 1; | 393 exit 1; |
394 fi | 394 fi |
395 } | 395 } |
396 | 396 |
397 function show_help { | 397 function show_help { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 if [ $PROCESSED_FILE != 0 ]; then | 539 if [ $PROCESSED_FILE != 0 ]; then |
540 let diff=$TOTAL_OLD_BYTES-$TOTAL_NEW_BYTES | 540 let diff=$TOTAL_OLD_BYTES-$TOTAL_NEW_BYTES |
541 let percent=$diff*100/$TOTAL_OLD_BYTES | 541 let percent=$diff*100/$TOTAL_OLD_BYTES |
542 echo "Result: $TOTAL_OLD_BYTES => $TOTAL_NEW_BYTES bytes" \ | 542 echo "Result: $TOTAL_OLD_BYTES => $TOTAL_NEW_BYTES bytes" \ |
543 "($diff bytes: $percent%)" | 543 "($diff bytes: $percent%)" |
544 fi | 544 fi |
545 if [ $CORRUPTED_FILE != 0 ]; then | 545 if [ $CORRUPTED_FILE != 0 ]; then |
546 echo "Warning: corrupted files found: $CORRUPTED_FILE" | 546 echo "Warning: corrupted files found: $CORRUPTED_FILE" |
547 echo "Please contact the author of the CL that landed corrupted png files" | 547 echo "Please contact the author of the CL that landed corrupted png files" |
548 fi | 548 fi |
OLD | NEW |