def _do_export(self, density, input_path, drawable):
     nonspecific = ".nonspecific." in input_path
     noflip = nonspecific or input_path.endswith(".noflip.svg")
     file_name = os.path.basename(os.path.splitext(input_path)[0].split(".")[0] + ".png")
     folder_path = os.path.join(OUTPUT_PATH_PREFIX, drawable)
     sh.mkdir("-p", folder_path)
     output_file_path = os.path.join(folder_path, file_name)
     output_precrush_path = output_file_path + "_"
     px = int(DENSITIES[density] * self.dp)
     sh.rsvg_convert(input_path, "-a", h=px, o=output_precrush_path)
     sh.pngcrush("-q", "-reduce", output_precrush_path, output_file_path)
     sh.rm(output_precrush_path)
     return output_file_path, noflip
def export(dp, density, filepath, drawable):
    noflip = '.nonspecific.' in filepath or filepath.endswith('.noflip.svg')
    filename = os.path.basename(filepath)
    new_filename = filename[:filename.index('.')] + '.png'
    folder_path = os.path.join(OUTPUT_PATH_PREFIX, drawable)
    sh.mkdir('-p', folder_path)
    output_file_path = os.path.join(folder_path, new_filename)
    output_precrush_path = output_file_path + '_'
    px = int(DENSITIES[density] * dp)
    sh.rsvg_convert(filepath, '-a', h=px, o=output_precrush_path)
    sh.pngcrush('-q', '-reduce', output_precrush_path, output_file_path)
    sh.rm(output_precrush_path)
    return output_file_path, noflip
Esempio n. 3
0
def export(dp, density, filepath, drawable):
    noflip = '.nonspecific.' in filepath or filepath.endswith('.noflip.svg')
    filename = os.path.basename(filepath)
    new_filename = filename[:filename.index('.')] + '.png'
    folder_path = os.path.join(OUTPUT_PATH_PREFIX, drawable)
    sh.mkdir('-p', folder_path)
    output_file_path = os.path.join(folder_path, new_filename)
    output_precrush_path = output_file_path + '_'
    px = int(DENSITIES[density] * dp)
    sh.rsvg_convert(filepath, '-a', h=px, o=output_precrush_path)
    sh.pngcrush('-q', '-reduce', output_precrush_path, output_file_path)
    sh.rm(output_precrush_path)
    return output_file_path, noflip
Esempio n. 4
0
 def _do_export(self, density, input_path, drawable):
     nonspecific = ".nonspecific." in input_path
     noflip = nonspecific or input_path.endswith(".noflip.svg")
     file_name = os.path.basename(os.path.splitext(input_path)[0].split(".")[0] + ".png")
     folder_path = os.path.join(OUTPUT_PATH_PREFIX, drawable)
     sh.mkdir("-p", folder_path)
     output_file_path = os.path.join(folder_path, file_name)
     output_precrush_path = output_file_path + "_"
     px = int(DENSITIES[density] * self.dp)
     sh.rsvg_convert(input_path, "-a", h=px, o=output_precrush_path)
     sh.pngcrush("-q", "-reduce", output_precrush_path, output_file_path)
     sh.rm(output_precrush_path)
     return (output_file_path, noflip)
Esempio n. 5
0
 def optimize_png_crush(filename, out_filename):
     log.debug('pngcrush optimization...')
     sh.pngcrush('-no_cc', '-rem', 'alla', '-brute', '-l', '9', '-z', '1',
                 '-reduce', '-q', filename, out_filename)