Skip to content

Commit c7e1fb7

Browse files
authored
Add files via upload
1 parent eac134d commit c7e1fb7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

script/pixel_converter.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22
import re
33
import cv2
44
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
67

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):
89
# k is color num
910
# scale is pixel size
1011
# to_tw means to twitter
1112
img_path.replace("\\", "/")
1213
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)
1523
return img_res
1624

1725
def save_cv_img(img, img_path, img_name):

0 commit comments

Comments
 (0)