TA的每日心情 | 开心 昨天 03:54 |
---|
签到天数: 564 天 [LV.9]以坛为家II
至尊会员
- 积分
- 177703
|
本帖最后由 偷懒的小蜜蜂 于 2023-8-18 20:33 编辑
自己改的py,应该可以放出吧
- import os, subprocess
- dir = input('Scan folder > ').replace('"','')
- dir_out = dir + '_webp'
- file_list = []
- for root, dirs, files in os.walk(dir):
- for name in files:
- file_list.append(os.path.join(root, name))
- for in_file in [i for i in file_list if '.png' in i]:
- out_file = in_file.replace(dir, dir_out).replace('.png', '.webp')
- os.makedirs(os.path.dirname(out_file), exist_ok=True)
- file_size = os.path.getsize(in_file) / 1048576
- if file_size >= 50:
- subprocess.run(['ffmpeg', '-i', in_file, '-vf', 'scale=iw/2:ih/2', '-sws_flags', 'bicubic', '-lossless', '1', out_file], shell=True)
- elif file_size >= 30:
- subprocess.run(['ffmpeg', '-i', in_file, '-vf', 'scale=iw/1.5:ih/1.5', '-sws_flags', 'bicubic', '-lossless', '1', out_file], shell=True)
- else:
- subprocess.run(['ffmpeg', '-i', in_file, '-lossless', '1', out_file], shell=True)
复制代码 按原始体积判断,对体积大于30MB的图出重拳 |
|