Skip to content

Commit 6246f35

Browse files
authored
Update rjj.py
1 parent c86160a commit 6246f35

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

rjj.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# !/usr/bin/env python3
22

3-
__version__="0.9.3"
3+
__version__="0.9.4"
44

55
import argparse, io, os, json, csv, glob, hashlib, warnings, base64, random, math
66
from sklearn.base import BaseEstimator, TransformerMixin
@@ -39,6 +39,31 @@ def create_png():
3939
generate_png(file_path, int(png_width), int(png_height))
4040
print(f"PNG file generated at: {file_path}")
4141

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+
4267
def minify_html(html_content):
4368
import re
4469
html_content = re.sub(r'<!--.*?-->', '', html_content, flags=re.DOTALL)
@@ -3523,6 +3548,7 @@ def __init__():
35233548
subparsers.add_parser('mj', help='minify json')
35243549
subparsers.add_parser('mh', help='minify html')
35253550
subparsers.add_parser('png', help='create transparent png')
3551+
subparsers.add_parser('gif', help='create gif animation')
35263552
subparsers.add_parser('cut', help='cut timestamp')
35273553
subparsers.add_parser('glue', help='glue timestamp')
35283554
subparsers.add_parser('code', help='encode or decode')
@@ -3572,6 +3598,8 @@ def __init__():
35723598
base64codeHandler()
35733599
elif args.subcommand == 'json':
35743600
json_merger()
3601+
elif args.subcommand == 'gif':
3602+
create_gif()
35753603
elif args.subcommand == 'png':
35763604
create_png()
35773605
elif args.subcommand == 'cut':

0 commit comments

Comments
 (0)