|
2 | 2 | import re |
3 | 3 | import cv2 |
4 | 4 | from pixel_transform import transform |
5 | | -from settings import resource_path |
| 5 | +from gif_process import gif_edit |
| 6 | +from video_editor import video_edit |
6 | 7 |
|
7 | | -def convert(img_path, k=16, scale=1, blur=0, erode=0,alpha = True, to_tw = False, dither=False, saturation=0, contrast=0): |
| 8 | +def convert(img_path, set_dict): |
8 | 9 | # k is color num |
9 | 10 | # scale is pixel size |
10 | 11 | # to_tw means to twitter |
11 | 12 | img_path.replace("\\", "/") |
12 | 13 | img_file_name = re.split("/", img_path)[-1] |
13 | | - img_res = transform(img_path, k=k, scale=scale, blur=blur, erode=erode, alpha=alpha, to_tw=to_tw, dither=dither, saturation=saturation, contrast=contrast) |
14 | | - img_path = img_path.split(img_file_name)[0] |
| 14 | + img_file_format = img_file_name.split('.')[-1] |
| 15 | + if img_file_format in ['gif', 'GIF']: |
| 16 | + img_res = gif_edit(img_path, set_dict) |
| 17 | + elif img_file_format in ['mp4', 'avi', 'flv']: |
| 18 | + img_res = video_edit(img_path, set_dict) |
| 19 | + else: |
| 20 | + img_res = transform(img_path, set_dict) |
| 21 | + img_path = img_path.split(img_file_name)[0] |
| 22 | + # cv2.imshow('show', img_res) |
15 | 23 | return img_res |
16 | 24 |
|
17 | 25 | def save_cv_img(img, img_path, img_name): |
|
0 commit comments