Initial commit
This commit is contained in:
commit
18ebcef492
956 files changed
+22301
No files matched your search
@@ -0,0 +1,23 @@
|
||||
"""Extract first frame + generate small static posters from animated webp."""
|
||||
import sys
|
||||
from PIL import Image
|
||||
|
||||
def main():
|
||||
srcs = [
|
||||
("Work_files/Planet/planet_mobile.webp", "Work_files/Planet/planet_poster_mobile.webp", 320),
|
||||
("Work_files/Planet/planet_15fps.webp", "Work_files/Planet/planet_poster.webp", 400),
|
||||
]
|
||||
for src, out, max_w in srcs:
|
||||
im = Image.open(src)
|
||||
im.seek(0)
|
||||
frame = im.convert("RGBA")
|
||||
# downscale to the file's native width if larger
|
||||
if frame.width > max_w:
|
||||
h = round(frame.height * max_w / frame.width)
|
||||
frame = frame.resize((max_w, h), Image.LANCZOS)
|
||||
frame.save(out, "WEBP", quality=75, method=6)
|
||||
import os
|
||||
print(f"{out}: {frame.size} {os.path.getsize(out)} bytes")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user