repogif 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
repogif-0.0.2/PKG-INFO ADDED
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: repogif
3
+ Version: 0.0.2
4
+ Summary: Generate beautiful animated GIFs that mimic GitHub repo stars/forks with realistic visuals. Perfect for social sharing, repo previews, documentation, or just for fun.
5
+ Home-page: https://github.com/jhd3197/repogif
6
+ Author: Juan Denis
7
+ Author-email: juan@vene.co
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: Pillow
13
+ Requires-Dist: imageio
14
+ Requires-Dist: imageio-ffmpeg
15
+ Requires-Dist: numpy
16
+ Requires-Dist: playwright
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: classifier
20
+ Dynamic: description
21
+ Dynamic: description-content-type
22
+ Dynamic: home-page
23
+ Dynamic: requires-dist
24
+ Dynamic: summary
25
+
26
+ # RepoGif 🎥⭐
27
+
28
+ Generate beautiful animated GIFs that mimic GitHub repo stars/forks with realistic visuals.
29
+ Perfect for social sharing, repo previews, documentation, or just for fun.
30
+
31
+ ## Features
32
+
33
+ - 🌈 Gradient backgrounds with authentic GitHub styling
34
+ - 🎨 Web-based animation with HTML/CSS/JS for high-quality visuals
35
+ - ⚙️ Customizable repository name, star count, and fork count
36
+ - 🔍 High-fidelity captures using Puppeteer
37
+ <br><br>
38
+
39
+ > [!TIP]
40
+ > Starring this repo helps more developers discover RepoGif 🎥
41
+ >
42
+ > ![template1_1k](https://github.com/user-attachments/assets/bf87874c-e22a-45d3-a5d8-6c30d4de478a)
43
+ >
44
+ <br>
45
+
46
+ ## Install
47
+
48
+ ```bash
49
+ git clone https://github.com/yourname/RepoGif.git
50
+ cd RepoGif
51
+ pip install -e .
52
+ playwright install
53
+ ```
54
+
55
+ ### Dependencies
56
+
57
+ - Pillow - Image processing
58
+ - imageio - GIF creation
59
+ - imageio-ffmpeg - Video encoding support
60
+ - numpy - Numerical operations
61
+ - playwright - Browser automation
62
+
63
+ ## Usage
64
+
65
+ ### Call from Python:
66
+ ```python
67
+ from repogif.generator import generate_repo_gif
68
+
69
+ generate_repo_gif(repo_name="RepoGif", stars=250, forks=30, out="output.gif")
70
+ ```
71
+
72
+ ### Run from CLI (after install):
73
+ ```bash
74
+ repogif
75
+ ```
76
+
77
+ ### Advanced Options
78
+
79
+ You can customize various aspects of the generated GIF:
80
+
81
+ ```python
82
+ generate_repo_gif(
83
+ repo_name="MyAwesomeProject",
84
+ stars="5.8k", # Supports string format for larger numbers
85
+ forks=397,
86
+ out="custom_animation.gif"
87
+ )
88
+ ```
89
+
90
+ ## How It Works
91
+
92
+ RepoGif uses a multi-step process to create high-quality animations:
93
+
94
+ 1. Uses static HTML templates with customizable parameters via URL query strings
95
+ 2. Uses Playwright to capture two frames (unstarred and starred states)
96
+ 3. Creates final GIF using PIL with 1-second duration per frame
97
+
98
+ The template-based approach allows for visually appealing animations with:
99
+ - Gradient backgrounds
100
+ - Proper GitHub styling and iconography
101
+ - Realistic cursor positioning
102
+ - Star button interactions with visual feedback
103
+
104
+ ## Customization
105
+
106
+ The templates are located in `repogif/templates/`, with each template in its own directory:
107
+ - Each template has its own template.html file and necessary assets
108
+ - Templates can be customized via URL parameters:
109
+ - Repository name
110
+ - Star count
111
+ - Fork count
112
+ - Display dimensions
113
+ - You can also create new templates following the existing structure
114
+
115
+ ---
116
+
117
+ 👉 This repo is fully usable right now. Just run:
118
+
119
+ ```bash
120
+ python examples/example.py
121
+ ```
122
+
123
+ and you'll get a RepoGif output in the examples/ folder 🎥.
124
+
125
+ ## Templates
126
+
127
+ RepoGif offers a variety of templates to showcase your repository in different styles and formats. Choose the one that best suits your needs.
128
+
129
+ ### Template 1 - Simple Star Animation
130
+
131
+ A simple 2-frame GIF showing star button animation with authentic GitHub styling.
132
+
133
+ ![template1_1k](https://github.com/user-attachments/assets/8481b384-8f3f-432e-bc64-33fccde73c6f)
134
+
135
+
136
+ **Default Dimensions**: Variable based on content
137
+
138
+ **Variants**:
139
+ - ![template1_no_forks](https://github.com/user-attachments/assets/ec88df4b-9e02-4d60-a9dd-dc7320bf62ec)
140
+ - ![template1_100stars](https://github.com/user-attachments/assets/dc08e923-31ef-4020-8d85-a550737cac9a)
141
+
142
+ ### Template 2 - Square Badge
143
+
144
+ A square badge displaying repository statistics with clean, modern design.
145
+
146
+ ![square_badge_test](https://github.com/user-attachments/assets/f4956ab0-ee3a-47f1-a3b8-8aa15555ee10)
147
+
148
+ **Default Dimensions**: 250x250 pixels
149
+
150
+ ### Template 3 - Horizontal Banner
151
+
152
+ A wide banner perfect for repository headers or documentation pages.
153
+
154
+ ![horizontal_banner_test](https://github.com/user-attachments/assets/4c2c7d0d-8826-40d5-82be-fa83bfbafc9c)
155
+
156
+ **Default Dimensions**: 600x120 pixels
157
+
158
+ ### Template 4 - Circular Badge
159
+
160
+ A circular badge with focused repository statistics in a compact form.
161
+
162
+ ![circular_badge_test](https://github.com/user-attachments/assets/6910f76f-30ad-4545-957d-4473b688f61a)
163
+
164
+ **Default Dimensions**: 250x250 pixels
165
+
166
+ ### Template 5 - Vertical Card
167
+
168
+ A vertical card layout with gradient background for an elegant presentation.
169
+
170
+ ![vertical_card_test](https://github.com/user-attachments/assets/f6830676-8950-4499-ba00-a5e6589ac47b)
171
+
172
+ **Default Dimensions**: 300x400 pixels
173
+
174
+ ### Template 6 - Minimalist Tile
175
+
176
+ A clean, monochrome design focusing on essential repository information.
177
+
178
+ ![minimalist_tile_test](https://github.com/user-attachments/assets/0ed364f5-68c1-4b2d-a2ba-bbc6d6fdec1c)
179
+
180
+ **Default Dimensions**: 320x200 pixels
181
+
182
+ ### Template 7 - Animated Badge
183
+
184
+ An eye-catching badge with pulsing star effect animation.
185
+
186
+ ![animated_badge_test](https://github.com/user-attachments/assets/faaecbe6-09a3-40f5-9dfa-092a71c9c846)
187
+
188
+ **Default Dimensions**: 280x280 pixels
189
+
190
+ ### Template 8 - Commit Pattern
191
+
192
+ ![template8_default](https://github.com/user-attachments/assets/43284e90-93f2-402b-b835-1b94fc037a17)
193
+
194
+ **Variants**:
195
+ - ![template8_increasing](https://github.com/user-attachments/assets/9d2ff7d7-f2a4-4384-b520-7358810cdd25)
196
+ - ![template8_with_zeros](https://github.com/user-attachments/assets/e1666ee3-8ae6-4fce-a04d-e6cc9be12480)
197
+
198
+ ### Template 9 - Contributors
199
+
200
+ ![template9_clustered](https://github.com/user-attachments/assets/adb8bff4-8719-4e04-8e6e-0b9b03e60f13)
201
+
202
+ **Variants**:
203
+ - ![template9_large](https://github.com/user-attachments/assets/2f34be6d-be2a-494d-822b-edab90c3af82)
204
+ - ![template9_small](https://github.com/user-attachments/assets/2fab08a1-b792-4088-b49c-85093b5f03f2)
205
+
206
+
207
+ ## Troubleshooting
208
+
209
+ ### Common Issues
210
+
211
+
212
+ #### Blank or Corrupted GIF
213
+ This could be due to:
214
+ - Frame capture issues - Check for browser compatibility
215
+ - Puppeteer configuration - Try running with different arguments
216
+ - File path problems - Ensure all paths are correct
217
+
218
+ ## Example Output
219
+ When run, this package generates an animated GIF showing a GitHub repository with stars and forks, along with a realistic cursor animation.
@@ -0,0 +1,194 @@
1
+ # RepoGif 🎥⭐
2
+
3
+ Generate beautiful animated GIFs that mimic GitHub repo stars/forks with realistic visuals.
4
+ Perfect for social sharing, repo previews, documentation, or just for fun.
5
+
6
+ ## Features
7
+
8
+ - 🌈 Gradient backgrounds with authentic GitHub styling
9
+ - 🎨 Web-based animation with HTML/CSS/JS for high-quality visuals
10
+ - ⚙️ Customizable repository name, star count, and fork count
11
+ - 🔍 High-fidelity captures using Puppeteer
12
+ <br><br>
13
+
14
+ > [!TIP]
15
+ > Starring this repo helps more developers discover RepoGif 🎥
16
+ >
17
+ > ![template1_1k](https://github.com/user-attachments/assets/bf87874c-e22a-45d3-a5d8-6c30d4de478a)
18
+ >
19
+ <br>
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ git clone https://github.com/yourname/RepoGif.git
25
+ cd RepoGif
26
+ pip install -e .
27
+ playwright install
28
+ ```
29
+
30
+ ### Dependencies
31
+
32
+ - Pillow - Image processing
33
+ - imageio - GIF creation
34
+ - imageio-ffmpeg - Video encoding support
35
+ - numpy - Numerical operations
36
+ - playwright - Browser automation
37
+
38
+ ## Usage
39
+
40
+ ### Call from Python:
41
+ ```python
42
+ from repogif.generator import generate_repo_gif
43
+
44
+ generate_repo_gif(repo_name="RepoGif", stars=250, forks=30, out="output.gif")
45
+ ```
46
+
47
+ ### Run from CLI (after install):
48
+ ```bash
49
+ repogif
50
+ ```
51
+
52
+ ### Advanced Options
53
+
54
+ You can customize various aspects of the generated GIF:
55
+
56
+ ```python
57
+ generate_repo_gif(
58
+ repo_name="MyAwesomeProject",
59
+ stars="5.8k", # Supports string format for larger numbers
60
+ forks=397,
61
+ out="custom_animation.gif"
62
+ )
63
+ ```
64
+
65
+ ## How It Works
66
+
67
+ RepoGif uses a multi-step process to create high-quality animations:
68
+
69
+ 1. Uses static HTML templates with customizable parameters via URL query strings
70
+ 2. Uses Playwright to capture two frames (unstarred and starred states)
71
+ 3. Creates final GIF using PIL with 1-second duration per frame
72
+
73
+ The template-based approach allows for visually appealing animations with:
74
+ - Gradient backgrounds
75
+ - Proper GitHub styling and iconography
76
+ - Realistic cursor positioning
77
+ - Star button interactions with visual feedback
78
+
79
+ ## Customization
80
+
81
+ The templates are located in `repogif/templates/`, with each template in its own directory:
82
+ - Each template has its own template.html file and necessary assets
83
+ - Templates can be customized via URL parameters:
84
+ - Repository name
85
+ - Star count
86
+ - Fork count
87
+ - Display dimensions
88
+ - You can also create new templates following the existing structure
89
+
90
+ ---
91
+
92
+ 👉 This repo is fully usable right now. Just run:
93
+
94
+ ```bash
95
+ python examples/example.py
96
+ ```
97
+
98
+ and you'll get a RepoGif output in the examples/ folder 🎥.
99
+
100
+ ## Templates
101
+
102
+ RepoGif offers a variety of templates to showcase your repository in different styles and formats. Choose the one that best suits your needs.
103
+
104
+ ### Template 1 - Simple Star Animation
105
+
106
+ A simple 2-frame GIF showing star button animation with authentic GitHub styling.
107
+
108
+ ![template1_1k](https://github.com/user-attachments/assets/8481b384-8f3f-432e-bc64-33fccde73c6f)
109
+
110
+
111
+ **Default Dimensions**: Variable based on content
112
+
113
+ **Variants**:
114
+ - ![template1_no_forks](https://github.com/user-attachments/assets/ec88df4b-9e02-4d60-a9dd-dc7320bf62ec)
115
+ - ![template1_100stars](https://github.com/user-attachments/assets/dc08e923-31ef-4020-8d85-a550737cac9a)
116
+
117
+ ### Template 2 - Square Badge
118
+
119
+ A square badge displaying repository statistics with clean, modern design.
120
+
121
+ ![square_badge_test](https://github.com/user-attachments/assets/f4956ab0-ee3a-47f1-a3b8-8aa15555ee10)
122
+
123
+ **Default Dimensions**: 250x250 pixels
124
+
125
+ ### Template 3 - Horizontal Banner
126
+
127
+ A wide banner perfect for repository headers or documentation pages.
128
+
129
+ ![horizontal_banner_test](https://github.com/user-attachments/assets/4c2c7d0d-8826-40d5-82be-fa83bfbafc9c)
130
+
131
+ **Default Dimensions**: 600x120 pixels
132
+
133
+ ### Template 4 - Circular Badge
134
+
135
+ A circular badge with focused repository statistics in a compact form.
136
+
137
+ ![circular_badge_test](https://github.com/user-attachments/assets/6910f76f-30ad-4545-957d-4473b688f61a)
138
+
139
+ **Default Dimensions**: 250x250 pixels
140
+
141
+ ### Template 5 - Vertical Card
142
+
143
+ A vertical card layout with gradient background for an elegant presentation.
144
+
145
+ ![vertical_card_test](https://github.com/user-attachments/assets/f6830676-8950-4499-ba00-a5e6589ac47b)
146
+
147
+ **Default Dimensions**: 300x400 pixels
148
+
149
+ ### Template 6 - Minimalist Tile
150
+
151
+ A clean, monochrome design focusing on essential repository information.
152
+
153
+ ![minimalist_tile_test](https://github.com/user-attachments/assets/0ed364f5-68c1-4b2d-a2ba-bbc6d6fdec1c)
154
+
155
+ **Default Dimensions**: 320x200 pixels
156
+
157
+ ### Template 7 - Animated Badge
158
+
159
+ An eye-catching badge with pulsing star effect animation.
160
+
161
+ ![animated_badge_test](https://github.com/user-attachments/assets/faaecbe6-09a3-40f5-9dfa-092a71c9c846)
162
+
163
+ **Default Dimensions**: 280x280 pixels
164
+
165
+ ### Template 8 - Commit Pattern
166
+
167
+ ![template8_default](https://github.com/user-attachments/assets/43284e90-93f2-402b-b835-1b94fc037a17)
168
+
169
+ **Variants**:
170
+ - ![template8_increasing](https://github.com/user-attachments/assets/9d2ff7d7-f2a4-4384-b520-7358810cdd25)
171
+ - ![template8_with_zeros](https://github.com/user-attachments/assets/e1666ee3-8ae6-4fce-a04d-e6cc9be12480)
172
+
173
+ ### Template 9 - Contributors
174
+
175
+ ![template9_clustered](https://github.com/user-attachments/assets/adb8bff4-8719-4e04-8e6e-0b9b03e60f13)
176
+
177
+ **Variants**:
178
+ - ![template9_large](https://github.com/user-attachments/assets/2f34be6d-be2a-494d-822b-edab90c3af82)
179
+ - ![template9_small](https://github.com/user-attachments/assets/2fab08a1-b792-4088-b49c-85093b5f03f2)
180
+
181
+
182
+ ## Troubleshooting
183
+
184
+ ### Common Issues
185
+
186
+
187
+ #### Blank or Corrupted GIF
188
+ This could be due to:
189
+ - Frame capture issues - Check for browser compatibility
190
+ - Puppeteer configuration - Try running with different arguments
191
+ - File path problems - Ensure all paths are correct
192
+
193
+ ## Example Output
194
+ When run, this package generates an animated GIF showing a GitHub repository with stars and forks, along with a realistic cursor animation.
@@ -0,0 +1,3 @@
1
+ from .generator import generate_repo_gif
2
+
3
+ __all__ = ['generate_repo_gif']
@@ -0,0 +1,256 @@
1
+ """
2
+ RepoGif - Generator for GitHub repository header GIFs.
3
+
4
+ This module provides the main functionality for generating GitHub repository
5
+ header GIFs using customizable templates.
6
+ """
7
+
8
+ import os
9
+ import tempfile
10
+ import shutil
11
+ import importlib
12
+ from pathlib import Path
13
+ from PIL import Image
14
+
15
+
16
+ class RepoGifGenerator:
17
+ """
18
+ Template-based GitHub repository header GIF generator.
19
+ This class provides a framework for generating repository header GIFs
20
+ using various templates.
21
+ """
22
+
23
+ def __init__(self):
24
+ """Initialize the generator with available templates."""
25
+ self.templates = {
26
+ "template1": "repogif.templates.template1",
27
+ "template2": "repogif.templates.template2",
28
+ "template3": "repogif.templates.template3",
29
+ "template4": "repogif.templates.template4",
30
+ "template5": "repogif.templates.template5",
31
+ "template6": "repogif.templates.template6",
32
+ "template7": "repogif.templates.template7",
33
+ "template8": "repogif.templates.template8",
34
+ "template9": "repogif.templates.template9"
35
+ }
36
+ self.default_template = "template1"
37
+
38
+ def get_available_templates(self):
39
+ """Returns a list of available template names."""
40
+ return list(self.templates.keys())
41
+
42
+ def generate_gif(self,
43
+ repo_name="repogif",
44
+ stars=123,
45
+ forks=45,
46
+ out="repo.gif",
47
+ debug_dir=None,
48
+ show_forks=True,
49
+ template=None,
50
+ width=580,
51
+ height=140,
52
+ contributors=None,
53
+ commits=None):
54
+ """
55
+ Generate a GitHub repository header GIF using the specified template.
56
+
57
+ Args:
58
+ repo_name (str): Name of the repository
59
+ stars (int/str): Number of stars to display
60
+ forks (int/str): Number of forks to display
61
+ out (str): Output path for the GIF
62
+ debug_dir (str/bool, optional): Directory to save frame images for debugging purposes.
63
+ If None or False, frames are not saved.
64
+ If True, frames are saved to a default directory in the package.
65
+ If a string path, frames are saved to that directory.
66
+ show_forks (bool, optional): Whether to display the fork section in the repository header.
67
+ template (str, optional): The template to use for generating the GIF.
68
+ If None, the default template will be used.
69
+ width (int, optional): Width of the GIF in pixels. Default is 580.
70
+ height (int, optional): Height of the GIF in pixels. Default is 140.
71
+ contributors (str, optional): JSON-encoded string of contributors data for template9.
72
+ Each contributor should have 'date', 'login', and 'avatar_url'.
73
+ commits (str, optional): Comma-separated string of weekly commit counts for template8.
74
+ Example: "10,25,15,30,20,35,40"
75
+
76
+ Returns:
77
+ None: The GIF is saved to the specified path
78
+
79
+ Raises:
80
+ ValueError: If the specified template is not available
81
+ RuntimeError: If required dependencies are not available
82
+ """
83
+ # Choose template (use default if not specified)
84
+ template_name = template or self.default_template
85
+
86
+ if template_name not in self.templates:
87
+ available = ", ".join(self.get_available_templates())
88
+ raise ValueError(f"Template '{template_name}' not found. Available templates: {available}")
89
+
90
+ # Import the template
91
+ try:
92
+ from playwright.sync_api import sync_playwright
93
+ except ImportError:
94
+ raise RuntimeError(
95
+ "Required dependencies not found. Please install with:\n"
96
+ "pip install playwright pillow\n"
97
+ "Then run: playwright install"
98
+ )
99
+
100
+ # Get the template path
101
+ template_module = self.templates[template_name]
102
+ template_dir = os.path.join(os.path.dirname(__file__),
103
+ "templates",
104
+ template_name)
105
+ template_path = os.path.join(template_dir, "template.html")
106
+ template_url = f"file://{os.path.abspath(template_path)}"
107
+
108
+ # Create temporary directory for frames
109
+ with tempfile.TemporaryDirectory() as temp_dir:
110
+ try:
111
+ # File paths for the two states
112
+ unstarred_path = os.path.join(temp_dir, "unstarred.png")
113
+ starred_path = os.path.join(temp_dir, "starred.png")
114
+
115
+ print("Capturing screenshots with Playwright...")
116
+ with sync_playwright() as p:
117
+ browser = p.chromium.launch()
118
+ # Set viewport to the specified dimensions
119
+ page = browser.new_page(viewport={"width": width, "height": height})
120
+
121
+ # Capture unstarred state
122
+ print("Capturing unstarred state...")
123
+ params = {
124
+ "repo_name": repo_name,
125
+ "stars": stars,
126
+ "forks": forks,
127
+ "starred": "false",
128
+ "show_forks": "true" if show_forks else "false",
129
+ "width": width,
130
+ "height": height
131
+ }
132
+
133
+ # Add commits data for template8
134
+ if commits and template_name == "template8":
135
+ params["commits"] = commits
136
+
137
+ # Add contributors data for template9
138
+ if contributors and template_name == "template9":
139
+ params["contributors"] = contributors
140
+ params["animation_state"] = "initial"
141
+ query_string = "&".join([f"{k}={v}" for k, v in params.items()])
142
+ page.goto(f"{template_url}?{query_string}")
143
+ page.screenshot(path=unstarred_path)
144
+
145
+ # Capture starred state
146
+ print("Capturing starred state...")
147
+ params["starred"] = "true"
148
+
149
+ # Update animation state for template9
150
+ if contributors and template_name == "template9":
151
+ params["animation_state"] = "animated"
152
+
153
+ query_string = "&".join([f"{k}={v}" for k, v in params.items()])
154
+ page.goto(f"{template_url}?{query_string}")
155
+ page.screenshot(path=starred_path)
156
+
157
+ browser.close()
158
+
159
+ # Create GIF from the two frames using PIL
160
+ print("Creating GIF from screenshots...")
161
+ frames = [Image.open(unstarred_path), Image.open(starred_path)]
162
+ frames[0].save(
163
+ out,
164
+ format='GIF',
165
+ append_images=[frames[1]],
166
+ save_all=True,
167
+ duration=1000, # 1 second per frame
168
+ loop=0 # Loop forever
169
+ )
170
+ print(f"✅ Saved {out}")
171
+
172
+ # Handle debug frames if debug_dir is provided
173
+ if debug_dir is not None and debug_dir is not False:
174
+ # If debug_dir is True, use the default debug directory in the package
175
+ if debug_dir is True:
176
+ debug_dir = os.path.join(os.path.dirname(__file__), "debug_frames")
177
+ print(f"Debug mode: using default debug directory: {debug_dir}")
178
+ else:
179
+ print(f"Debug mode: copying frames to {debug_dir}")
180
+
181
+ try:
182
+ # Create debug directory if it doesn't exist
183
+ if not os.path.exists(debug_dir):
184
+ os.makedirs(debug_dir)
185
+ print(f"Created debug directory: {debug_dir}")
186
+
187
+ # Copy frames to the debug directory
188
+ frame_files = [unstarred_path, starred_path]
189
+ frame_names = ["unstarred.png", "starred.png"]
190
+
191
+ for i, frame_file in enumerate(frame_files):
192
+ dest_path = os.path.join(debug_dir, frame_names[i])
193
+ shutil.copy2(frame_file, dest_path)
194
+
195
+ print(f"✅ Copied frames to {debug_dir}")
196
+ except PermissionError:
197
+ print(f"⚠️ Warning: Permission denied when copying frames to {debug_dir}")
198
+ except OSError as e:
199
+ print(f"⚠️ Warning: Failed to copy frames to debug directory: {e}")
200
+
201
+ except Exception as e:
202
+ raise RuntimeError(f"Error generating GIF: {e}")
203
+
204
+
205
+ # Create a singleton instance of the generator
206
+ _generator = RepoGifGenerator()
207
+
208
+
209
+ # Public API functions
210
+ def generate_repo_gif(repo_name="repogif", stars=123, forks=45, out="repo.gif",
211
+ debug_dir=None, show_forks=True, template=None,
212
+ width=580, height=140, contributors=None, commits=None):
213
+ """
214
+ Generate a GitHub repository header GIF using the specified template.
215
+
216
+ Args:
217
+ repo_name (str): Name of the repository
218
+ stars (int/str): Number of stars to display
219
+ forks (int/str): Number of forks to display
220
+ out (str): Output path for the GIF
221
+ debug_dir (str/bool, optional): Directory to save frame images for debugging purposes.
222
+ show_forks (bool, optional): Whether to display the fork section in the repository header.
223
+ template (str, optional): The template to use for generating the GIF.
224
+ If None, the default template will be used.
225
+ width (int, optional): Width of the GIF in pixels. Default is 580.
226
+ height (int, optional): Height of the GIF in pixels. Default is 140.
227
+ contributors (str, optional): JSON-encoded string of contributors data for template9.
228
+ Each contributor should have 'date', 'login', and 'avatar_url'.
229
+ commits (str, optional): Comma-separated string of weekly commit counts for template8.
230
+ Example: "10,25,15,30,20,35,40"
231
+
232
+ Returns:
233
+ None: The GIF is saved to the specified path
234
+ """
235
+ return _generator.generate_gif(
236
+ repo_name=repo_name,
237
+ stars=stars,
238
+ forks=forks,
239
+ out=out,
240
+ debug_dir=debug_dir,
241
+ show_forks=show_forks,
242
+ template=template,
243
+ width=width,
244
+ height=height,
245
+ contributors=contributors,
246
+ commits=commits
247
+ )
248
+
249
+
250
+ def get_available_templates():
251
+ """Returns a list of available template names."""
252
+ return _generator.get_available_templates()
253
+
254
+
255
+ # Define the public API
256
+ __all__ = ['generate_repo_gif', 'get_available_templates']
@@ -0,0 +1,3 @@
1
+ """
2
+ Templates package for RepoGif
3
+ """
@@ -0,0 +1,3 @@
1
+ """
2
+ Template 1 for RepoGif - A simple 2-frame GIF showing star button animation
3
+ """
@@ -0,0 +1,3 @@
1
+ """
2
+ Template 6 for RepoGif - A Square Badge (250x250) showing repository stats
3
+ """
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ """
2
+ Template 8 for RepoGif - A GitHub-style repository commits per week visualization
3
+ """
@@ -0,0 +1,74 @@
1
+ """
2
+ Template 9 for RepoGif - A visualization showing repository contributors growth over time
3
+
4
+ This template shows a GitHub-style visualization of repository contributors growth
5
+ over time. It includes a line/area chart and avatar visualization.
6
+ """
7
+
8
+ import json
9
+ from datetime import datetime
10
+ import urllib.parse
11
+
12
+ # This template handles contributors data, which should be provided as a JSON-encoded string
13
+ # Each contributor entry should contain:
14
+ # - date: ISO date string of first commit
15
+ # - login: GitHub username
16
+ # - avatar_url: URL to avatar image
17
+
18
+ def parse_contributors(contributors_json):
19
+ """
20
+ Parse the JSON-encoded contributors data and sort by date.
21
+
22
+ Args:
23
+ contributors_json (str): JSON-encoded string of contributors data
24
+
25
+ Returns:
26
+ list: Sorted list of contributor dictionaries
27
+ """
28
+ if not contributors_json:
29
+ # Return a default list if no contributors provided
30
+ return []
31
+
32
+ try:
33
+ contributors = json.loads(contributors_json)
34
+ # Sort contributors by date (earliest first)
35
+ return sorted(contributors, key=lambda x: x.get('date', ''))
36
+ except json.JSONDecodeError:
37
+ # Return empty list if JSON is invalid
38
+ return []
39
+
40
+ def prepare_template_params(repo_name, contributors_data, width=580, height=140):
41
+ """
42
+ Prepare parameters for template URL.
43
+
44
+ Args:
45
+ repo_name (str): Name of the repository
46
+ contributors_data (str): JSON-encoded string of contributors data
47
+ width (int): Width of the GIF in pixels
48
+ height (int): Height of the GIF in pixels
49
+
50
+ Returns:
51
+ dict: Dictionary of template parameters
52
+ """
53
+ # First animation state (initial)
54
+ initial_params = {
55
+ "repo_name": repo_name,
56
+ "contributors": urllib.parse.quote(contributors_data),
57
+ "animation_state": "initial",
58
+ "width": width,
59
+ "height": height
60
+ }
61
+
62
+ # Second animation state (animated)
63
+ animated_params = {
64
+ "repo_name": repo_name,
65
+ "contributors": urllib.parse.quote(contributors_data),
66
+ "animation_state": "animated",
67
+ "width": width,
68
+ "height": height
69
+ }
70
+
71
+ return {
72
+ "initial": initial_params,
73
+ "animated": animated_params
74
+ }
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: repogif
3
+ Version: 0.0.2
4
+ Summary: Generate beautiful animated GIFs that mimic GitHub repo stars/forks with realistic visuals. Perfect for social sharing, repo previews, documentation, or just for fun.
5
+ Home-page: https://github.com/jhd3197/repogif
6
+ Author: Juan Denis
7
+ Author-email: juan@vene.co
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: Pillow
13
+ Requires-Dist: imageio
14
+ Requires-Dist: imageio-ffmpeg
15
+ Requires-Dist: numpy
16
+ Requires-Dist: playwright
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: classifier
20
+ Dynamic: description
21
+ Dynamic: description-content-type
22
+ Dynamic: home-page
23
+ Dynamic: requires-dist
24
+ Dynamic: summary
25
+
26
+ # RepoGif 🎥⭐
27
+
28
+ Generate beautiful animated GIFs that mimic GitHub repo stars/forks with realistic visuals.
29
+ Perfect for social sharing, repo previews, documentation, or just for fun.
30
+
31
+ ## Features
32
+
33
+ - 🌈 Gradient backgrounds with authentic GitHub styling
34
+ - 🎨 Web-based animation with HTML/CSS/JS for high-quality visuals
35
+ - ⚙️ Customizable repository name, star count, and fork count
36
+ - 🔍 High-fidelity captures using Puppeteer
37
+ <br><br>
38
+
39
+ > [!TIP]
40
+ > Starring this repo helps more developers discover RepoGif 🎥
41
+ >
42
+ > ![template1_1k](https://github.com/user-attachments/assets/bf87874c-e22a-45d3-a5d8-6c30d4de478a)
43
+ >
44
+ <br>
45
+
46
+ ## Install
47
+
48
+ ```bash
49
+ git clone https://github.com/yourname/RepoGif.git
50
+ cd RepoGif
51
+ pip install -e .
52
+ playwright install
53
+ ```
54
+
55
+ ### Dependencies
56
+
57
+ - Pillow - Image processing
58
+ - imageio - GIF creation
59
+ - imageio-ffmpeg - Video encoding support
60
+ - numpy - Numerical operations
61
+ - playwright - Browser automation
62
+
63
+ ## Usage
64
+
65
+ ### Call from Python:
66
+ ```python
67
+ from repogif.generator import generate_repo_gif
68
+
69
+ generate_repo_gif(repo_name="RepoGif", stars=250, forks=30, out="output.gif")
70
+ ```
71
+
72
+ ### Run from CLI (after install):
73
+ ```bash
74
+ repogif
75
+ ```
76
+
77
+ ### Advanced Options
78
+
79
+ You can customize various aspects of the generated GIF:
80
+
81
+ ```python
82
+ generate_repo_gif(
83
+ repo_name="MyAwesomeProject",
84
+ stars="5.8k", # Supports string format for larger numbers
85
+ forks=397,
86
+ out="custom_animation.gif"
87
+ )
88
+ ```
89
+
90
+ ## How It Works
91
+
92
+ RepoGif uses a multi-step process to create high-quality animations:
93
+
94
+ 1. Uses static HTML templates with customizable parameters via URL query strings
95
+ 2. Uses Playwright to capture two frames (unstarred and starred states)
96
+ 3. Creates final GIF using PIL with 1-second duration per frame
97
+
98
+ The template-based approach allows for visually appealing animations with:
99
+ - Gradient backgrounds
100
+ - Proper GitHub styling and iconography
101
+ - Realistic cursor positioning
102
+ - Star button interactions with visual feedback
103
+
104
+ ## Customization
105
+
106
+ The templates are located in `repogif/templates/`, with each template in its own directory:
107
+ - Each template has its own template.html file and necessary assets
108
+ - Templates can be customized via URL parameters:
109
+ - Repository name
110
+ - Star count
111
+ - Fork count
112
+ - Display dimensions
113
+ - You can also create new templates following the existing structure
114
+
115
+ ---
116
+
117
+ 👉 This repo is fully usable right now. Just run:
118
+
119
+ ```bash
120
+ python examples/example.py
121
+ ```
122
+
123
+ and you'll get a RepoGif output in the examples/ folder 🎥.
124
+
125
+ ## Templates
126
+
127
+ RepoGif offers a variety of templates to showcase your repository in different styles and formats. Choose the one that best suits your needs.
128
+
129
+ ### Template 1 - Simple Star Animation
130
+
131
+ A simple 2-frame GIF showing star button animation with authentic GitHub styling.
132
+
133
+ ![template1_1k](https://github.com/user-attachments/assets/8481b384-8f3f-432e-bc64-33fccde73c6f)
134
+
135
+
136
+ **Default Dimensions**: Variable based on content
137
+
138
+ **Variants**:
139
+ - ![template1_no_forks](https://github.com/user-attachments/assets/ec88df4b-9e02-4d60-a9dd-dc7320bf62ec)
140
+ - ![template1_100stars](https://github.com/user-attachments/assets/dc08e923-31ef-4020-8d85-a550737cac9a)
141
+
142
+ ### Template 2 - Square Badge
143
+
144
+ A square badge displaying repository statistics with clean, modern design.
145
+
146
+ ![square_badge_test](https://github.com/user-attachments/assets/f4956ab0-ee3a-47f1-a3b8-8aa15555ee10)
147
+
148
+ **Default Dimensions**: 250x250 pixels
149
+
150
+ ### Template 3 - Horizontal Banner
151
+
152
+ A wide banner perfect for repository headers or documentation pages.
153
+
154
+ ![horizontal_banner_test](https://github.com/user-attachments/assets/4c2c7d0d-8826-40d5-82be-fa83bfbafc9c)
155
+
156
+ **Default Dimensions**: 600x120 pixels
157
+
158
+ ### Template 4 - Circular Badge
159
+
160
+ A circular badge with focused repository statistics in a compact form.
161
+
162
+ ![circular_badge_test](https://github.com/user-attachments/assets/6910f76f-30ad-4545-957d-4473b688f61a)
163
+
164
+ **Default Dimensions**: 250x250 pixels
165
+
166
+ ### Template 5 - Vertical Card
167
+
168
+ A vertical card layout with gradient background for an elegant presentation.
169
+
170
+ ![vertical_card_test](https://github.com/user-attachments/assets/f6830676-8950-4499-ba00-a5e6589ac47b)
171
+
172
+ **Default Dimensions**: 300x400 pixels
173
+
174
+ ### Template 6 - Minimalist Tile
175
+
176
+ A clean, monochrome design focusing on essential repository information.
177
+
178
+ ![minimalist_tile_test](https://github.com/user-attachments/assets/0ed364f5-68c1-4b2d-a2ba-bbc6d6fdec1c)
179
+
180
+ **Default Dimensions**: 320x200 pixels
181
+
182
+ ### Template 7 - Animated Badge
183
+
184
+ An eye-catching badge with pulsing star effect animation.
185
+
186
+ ![animated_badge_test](https://github.com/user-attachments/assets/faaecbe6-09a3-40f5-9dfa-092a71c9c846)
187
+
188
+ **Default Dimensions**: 280x280 pixels
189
+
190
+ ### Template 8 - Commit Pattern
191
+
192
+ ![template8_default](https://github.com/user-attachments/assets/43284e90-93f2-402b-b835-1b94fc037a17)
193
+
194
+ **Variants**:
195
+ - ![template8_increasing](https://github.com/user-attachments/assets/9d2ff7d7-f2a4-4384-b520-7358810cdd25)
196
+ - ![template8_with_zeros](https://github.com/user-attachments/assets/e1666ee3-8ae6-4fce-a04d-e6cc9be12480)
197
+
198
+ ### Template 9 - Contributors
199
+
200
+ ![template9_clustered](https://github.com/user-attachments/assets/adb8bff4-8719-4e04-8e6e-0b9b03e60f13)
201
+
202
+ **Variants**:
203
+ - ![template9_large](https://github.com/user-attachments/assets/2f34be6d-be2a-494d-822b-edab90c3af82)
204
+ - ![template9_small](https://github.com/user-attachments/assets/2fab08a1-b792-4088-b49c-85093b5f03f2)
205
+
206
+
207
+ ## Troubleshooting
208
+
209
+ ### Common Issues
210
+
211
+
212
+ #### Blank or Corrupted GIF
213
+ This could be due to:
214
+ - Frame capture issues - Check for browser compatibility
215
+ - Puppeteer configuration - Try running with different arguments
216
+ - File path problems - Ensure all paths are correct
217
+
218
+ ## Example Output
219
+ When run, this package generates an animated GIF showing a GitHub repository with stars and forks, along with a realistic cursor animation.
@@ -0,0 +1,21 @@
1
+ README.md
2
+ setup.py
3
+ repogif/__init__.py
4
+ repogif/generator.py
5
+ repogif.egg-info/PKG-INFO
6
+ repogif.egg-info/SOURCES.txt
7
+ repogif.egg-info/dependency_links.txt
8
+ repogif.egg-info/entry_points.txt
9
+ repogif.egg-info/requires.txt
10
+ repogif.egg-info/top_level.txt
11
+ repogif/templates/__init__.py
12
+ repogif/templates/template1/__init__.py
13
+ repogif/templates/template2/__init__.py
14
+ repogif/templates/template3/__init__.py
15
+ repogif/templates/template4/__init__.py
16
+ repogif/templates/template5/__init__.py
17
+ repogif/templates/template6/__init__.py
18
+ repogif/templates/template7/__init__.py
19
+ repogif/templates/template8/__init__.py
20
+ repogif/templates/template9/__init__.py
21
+ tests/test_generator.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ repogif = repogif.generator:generate_repo_gif
@@ -0,0 +1,5 @@
1
+ Pillow
2
+ imageio
3
+ imageio-ffmpeg
4
+ numpy
5
+ playwright
@@ -0,0 +1 @@
1
+ repogif
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
repogif-0.0.2/setup.py ADDED
@@ -0,0 +1,34 @@
1
+ from setuptools import setup, find_packages
2
+ from pathlib import Path
3
+
4
+ this_directory = Path(__file__).parent
5
+ long_description = (this_directory / "README.md").read_text(encoding="utf-8")
6
+
7
+ setup(
8
+ name="repogif",
9
+ version='0.0.2',
10
+ description="Generate beautiful animated GIFs that mimic GitHub repo stars/forks with realistic visuals. Perfect for social sharing, repo previews, documentation, or just for fun.",
11
+ author="Juan Denis",
12
+ author_email="juan@vene.co",
13
+ url="https://github.com/jhd3197/repogif",
14
+ packages=find_packages(),
15
+ install_requires=[
16
+ "Pillow",
17
+ "imageio",
18
+ "imageio-ffmpeg",
19
+ "numpy",
20
+ "playwright"
21
+ ],
22
+ classifiers=[
23
+ "Programming Language :: Python :: 3",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Operating System :: OS Independent",
26
+ ],
27
+ long_description=long_description,
28
+ long_description_content_type="text/markdown",
29
+ entry_points={
30
+ "console_scripts": [
31
+ "repogif=repogif.generator:generate_repo_gif",
32
+ ],
33
+ },
34
+ )
@@ -0,0 +1,7 @@
1
+ from repogif.generator import generate_repo_gif
2
+ import os
3
+
4
+ def test_generate():
5
+ out_file = "test.gif"
6
+ generate_repo_gif(repo_name="testrepo", stars=5, forks=2, out=out_file)
7
+ assert os.path.exists(out_file)