| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2014 Google Inc. All rights reserved. | 2 # Copyright (c) 2014 Google Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 sys.exit(1) | 72 sys.exit(1) |
| 73 | 73 |
| 74 check_installed("pngcrush", "pngcrush", None) | 74 check_installed("pngcrush", "pngcrush", None) |
| 75 check_installed("optipng", "optipng", None) | 75 check_installed("optipng", "optipng", None) |
| 76 check_installed("advdef", "advancecomp", None) | 76 check_installed("advdef", "advancecomp", None) |
| 77 check_installed("pngout", None, "Utility can be downloaded here: http://www.jono
f.id.au/kenutils") | 77 check_installed("pngout", None, "Utility can be downloaded here: http://www.jono
f.id.au/kenutils") |
| 78 | 78 |
| 79 | 79 |
| 80 def optimize_png(file_name): | 80 def optimize_png(file_name): |
| 81 png_full_path = images_path + "/" + file_name + ".png" | 81 png_full_path = images_path + "/" + file_name + ".png" |
| 82 optimize_command = "%s -o2 %s" % (optimize_script_path, png_full_path) | 82 optimize_command = "bash %s -o2 %s" % (optimize_script_path, png_full_path) |
| 83 proc = subprocess.Popen(optimize_command, stdout=subprocess.PIPE, stderr=sub
process.STDOUT, shell=True, cwd=chromium_src_path) | 83 proc = subprocess.Popen(optimize_command, stdout=subprocess.PIPE, stderr=sub
process.STDOUT, shell=True, cwd=chromium_src_path) |
| 84 return proc | 84 return proc |
| 85 | 85 |
| 86 if len(svg_file_names): | 86 if len(svg_file_names): |
| 87 print "%d unoptimized png files found." % len(svg_file_names) | 87 print "%d unoptimized png files found." % len(svg_file_names) |
| 88 else: | 88 else: |
| 89 print "All png files are already optimized." | 89 print "All png files are already optimized." |
| 90 sys.exit() | 90 sys.exit() |
| 91 | 91 |
| 92 processes = {} | 92 processes = {} |
| 93 for file_name in svg_file_names: | 93 for file_name in svg_file_names: |
| 94 name = re.sub(".svg$", "", file_name) | 94 name = re.sub(".svg$", "", file_name) |
| 95 name2x = name + "_2x" | 95 name2x = name + "_2x" |
| 96 processes[name] = optimize_png(name) | 96 processes[name] = optimize_png(name) |
| 97 processes[name2x] = optimize_png(name2x) | 97 processes[name2x] = optimize_png(name2x) |
| 98 | 98 |
| 99 for file_name, proc in processes.items(): | 99 for file_name, proc in processes.items(): |
| 100 (optimize_out, _) = proc.communicate() | 100 (optimize_out, _) = proc.communicate() |
| 101 print("Optimization of %s finished: %s" % (file_name, optimize_out)) | 101 print("Optimization of %s finished: %s" % (file_name, optimize_out)) |
| 102 | 102 |
| 103 devtools_file_hashes.update_file_hashes(hashes_file_path, svg_file_paths) | 103 devtools_file_hashes.update_file_hashes(hashes_file_path, svg_file_paths) |
| OLD | NEW |