def _ConvertToWebP(webp_binary, png_files):
pool = multiprocessing.pool.ThreadPool(10)
def convert_image(png_path):
root = os.path.splitext(png_path)[0]
webp_path = root + '.webp'
args = [webp_binary, png_path] + _PNG_TO_WEBP_ARGS + [webp_path]
subprocess.check_call(args)
os.remove(png_path)
# Android requires pngs for 9-patch images.
pool.map(convert_image, [f for f in png_files if not f.endswith('.9.png')])
pool.close()
pool.join()
评论列表
文章目录