|
1 | 1 | # !/usr/bin/env python3
|
2 | 2 |
|
3 |
| -__version__="0.9.3" |
| 3 | +__version__="0.9.4" |
4 | 4 |
|
5 | 5 | import argparse, io, os, json, csv, glob, hashlib, warnings, base64, random, math
|
6 | 6 | from sklearn.base import BaseEstimator, TransformerMixin
|
@@ -39,6 +39,31 @@ def create_png():
|
39 | 39 | generate_png(file_path, int(png_width), int(png_height))
|
40 | 40 | print(f"PNG file generated at: {file_path}")
|
41 | 41 |
|
| 42 | +def create_gif(): |
| 43 | + from PIL import Image |
| 44 | + num_pictures = int(input("Enter the number of pictures to include in the animation: ")) |
| 45 | + input_files = [] |
| 46 | + for i in range(num_pictures): |
| 47 | + filename = input(f"Enter the filename for picture {i + 1} (with .png extension): ") |
| 48 | + input_files.append(filename) |
| 49 | + transition_times = [] |
| 50 | + for i in range(num_pictures): |
| 51 | + duration = int(input(f"Enter the transition time (ms) for picture {i + 1}: ")) |
| 52 | + transition_times.append(duration) |
| 53 | + loop_number = int(input("Enter the loop number (0 for infinity): ")) |
| 54 | + frames = [] |
| 55 | + for file in input_files: |
| 56 | + img = Image.open(file) |
| 57 | + frames.append(img) |
| 58 | + frames[0].save( |
| 59 | + 'output.gif', |
| 60 | + save_all=True, |
| 61 | + append_images=frames[1:], |
| 62 | + duration=transition_times, |
| 63 | + loop=loop_number |
| 64 | + ) |
| 65 | + print("GIF animation created as 'output.gif'!") |
| 66 | + |
42 | 67 | def minify_html(html_content):
|
43 | 68 | import re
|
44 | 69 | html_content = re.sub(r'<!--.*?-->', '', html_content, flags=re.DOTALL)
|
@@ -3523,6 +3548,7 @@ def __init__():
|
3523 | 3548 | subparsers.add_parser('mj', help='minify json')
|
3524 | 3549 | subparsers.add_parser('mh', help='minify html')
|
3525 | 3550 | subparsers.add_parser('png', help='create transparent png')
|
| 3551 | + subparsers.add_parser('gif', help='create gif animation') |
3526 | 3552 | subparsers.add_parser('cut', help='cut timestamp')
|
3527 | 3553 | subparsers.add_parser('glue', help='glue timestamp')
|
3528 | 3554 | subparsers.add_parser('code', help='encode or decode')
|
@@ -3572,6 +3598,8 @@ def __init__():
|
3572 | 3598 | base64codeHandler()
|
3573 | 3599 | elif args.subcommand == 'json':
|
3574 | 3600 | json_merger()
|
| 3601 | + elif args.subcommand == 'gif': |
| 3602 | + create_gif() |
3575 | 3603 | elif args.subcommand == 'png':
|
3576 | 3604 | create_png()
|
3577 | 3605 | elif args.subcommand == 'cut':
|
|
0 commit comments