Example #1
0
 def __init__(self, size_limit, size_min, size_max, speed):
     self.size_limit = size_limit*1024
     self.size_min = size_min
     self.size_max = size_max
     self.speed = speed
     pqpath = None
     if sys.platform == 'win32':
         pqpath = 'pngquant/win32/pngquant.exe'
         self.pq = path2unix(pqpath)
     elif sys.platform == 'darwin':
         pqpath = 'pngquant/mac/pngquant'
         self.pq = path2unix(pqpath)
     else:
         pqpath = shutil.which('pngquant')
         self.pq = pqpath
Example #2
0
File: ic.py Project: rontgen/Mydemo
def read_config(*pathes):
    file_str = readfile(*pathes)
    seach_pattern = re.compile(r'(?<=image_folder_path\=).*')
    #input_path = re.search(r'(?<=image_folder_path\=).*', lambda m:'%s, %s'%(m.group(0), x), file_str)
    print ("## path2unix(os.path.abspath(__file__) = {:s}" .format(os.path.split(os.path.abspath(__file__))[0]))
    work_dir = os.path.split(os.path.abspath(__file__))[0] 
    for line in file_str:
        m = re.search(r'(?<=pngquant_path\=).*', line)
        if m:
            pngquant_path = path2unix(work_dir, m.group(0))
    for line in file_str:
        m = re.search(r'(?<=optipng_path\=).*', line)
        if m:
            optipng_path = path2unix(work_dir, m.group(0))
    return (pngquant_path, optipng_path)
Example #3
0
def read_confgig():
    __conf = INIConf()
    __conf.read("tp_config.ini", encoding='utf-8')
    list_cprs = []
    list_hqrs = []
    dict_pq_params = {}
    list_cprs = list(path2unix(item) for item in __conf['@list compress_input'] if item)
    list_hqrs = list(path2unix(item) for item in __conf['@list compress hq'] if item)
    for item in __conf['pngquant_params']:
        str_arr = item.split(':')
        if len(str_arr) == 2:
            dict_pq_params[str(str_arr[0])] = int(str_arr[1])
        else:
            raise SyntaxError("[img_comprs][read_confgig]: invalid config format")
            sys.exit(1024)
    return (list_cprs, list_hqrs, dict_pq_params)
Example #4
0
File: ic.py Project: rontgen/Mydemo
def main():
    print("hello pngquant {:s}" .format(path2unix(os.getcwd())))
    pngquant_path, optipng_path = read_config("tp_config.ini")
    print("pngquant_path = {:s}" .format(path2unix(pngquant_path)))