-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convertPNGtoWEBP.py
47 lines (36 loc) · 1.52 KB
/
convertPNGtoWEBP.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
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
# Use the proper idiom in the main module ...
# NOTE: See https://docs.python.org/3.11/library/multiprocessing.html#the-spawn-and-forkserver-start-methods
if __name__ == "__main__":
# Import standard modules ...
import glob
# Import my modules ...
try:
import pyguymer3
import pyguymer3.media
except:
raise Exception("\"pyguymer3\" is not installed; you need to have the Python module from https://github.com/Guymer/PyGuymer3 located somewhere in your $PYTHONPATH") from None
# **************************************************************************
# Find the frames ...
frames = sorted(glob.glob("createMask3_mask????.png"))
# **************************************************************************
print("Making \"createMask3.webp\" ...")
# Save 25fps WEBP ...
pyguymer3.media.images2webp(
frames,
"createMask3.webp",
)
# **************************************************************************
# Set maximum sizes ...
# NOTE: By inspection, the PNG frames are 2,160 px wide.
maxSizes = [512, 1024, 2048] # [px]
# Loop over maximum sizes ...
for maxSize in maxSizes:
print(f"Making \"createMask3{maxSize:04d}px.webp\" ...")
# Save 25fps WEBP ...
pyguymer3.media.images2webp(
frames,
f"createMask3{maxSize:04d}px.webp",
screenHeight = maxSize,
screenWidth = maxSize,
)