-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimg2gif.py
35 lines (26 loc) · 906 Bytes
/
img2gif.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from PIL import Image
import cv2
import os
import imageio
result = []
paths = 'D:/save/1004_212707'
images = []
for (root, dir, files) in os.walk(paths):
for file in files:
if str(file).endswith(".jpg"):
path = os.path.join(root, file)
img = cv2.imread(path)
img = cv2.resize(img, (320, 160), interpolation=cv2.INTER_AREA)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
result.append(img)
name = path.split(".jpg")[0]
cv2.imwrite(f'./pngs/{name}.png', img)
# path = os.path.join(root, file)
# images.append(imageio.imread(path))
# imageio.mimsave('D:/save/1007_180305/1007_180305.gif', images)
import matplotlib.pyplot as plt
import numpy as np
import imageio
from PIL import Image
import matplotlib.image as mpimg
imageio.mimsave('D:/save/1004_212707/1004_212707.gif', result)