Commit 9174e35
committed
feat: Calculate average FPS from GIF by default
Previously, the conversion defaulted to a fixed 10 FPS, which might not accurately reflect the original GIF's intended animation speed.
This change introduces the capability to calculate the average FPS based on the frame durations embedded within the input GIF file itself. This calculated average FPS is now the default behavior when no explicit FPS is provided by the user, leading to more accurate output animations out-of-the-box.
Changes include:
- Added `_calculate_gif_average_fps` to read frame durations and compute the average FPS, handling missing or zero durations.
- Modified `gif_to_animated_svg` and `gif_to_animated_svg_write` to accept `fps=None` (new default) to trigger this calculation.
- Renamed `DEFAULT_FPS` to `FALLBACK_FPS` (value remains 10.0) and use it if calculation fails (e.g., non-animated GIF, read errors) or if an invalid FPS is provided.
- Updated the CLI `--fps` argument: removed the explicit default value, allowing the calculation logic to take precedence. Help text updated.
- Updated the Web API `/api/convert` endpoint to align with the new library default behavior.
- Added comprehensive tests for the FPS calculation logic and its integration.
- Updated README documentation to reflect the new default FPS behavior for both CLI and library usage.
- Bumped project version to 0.2.0.1 parent 7938f26 commit 9174e35
File tree
6 files changed
+258
-70
lines changed- src/framesvg
- tests
- web/api
6 files changed
+258
-70
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
136 | 166 | | |
137 | 167 | | |
138 | 168 | | |
| |||
222 | 252 | | |
223 | 253 | | |
224 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
225 | 258 | | |
226 | 259 | | |
227 | 260 | | |
| |||
253 | 286 | | |
254 | 287 | | |
255 | 288 | | |
256 | | - | |
257 | | - | |
258 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
259 | 292 | | |
260 | 293 | | |
261 | 294 | | |
| |||
267 | 300 | | |
268 | 301 | | |
269 | 302 | | |
270 | | - | |
| 303 | + | |
271 | 304 | | |
272 | 305 | | |
273 | 306 | | |
| |||
282 | 315 | | |
283 | 316 | | |
284 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
285 | 329 | | |
286 | | - | |
| 330 | + | |
287 | 331 | | |
288 | 332 | | |
289 | 333 | | |
| |||
292 | 336 | | |
293 | 337 | | |
294 | 338 | | |
295 | | - | |
| 339 | + | |
296 | 340 | | |
297 | 341 | | |
298 | 342 | | |
| |||
342 | 386 | | |
343 | 387 | | |
344 | 388 | | |
345 | | - | |
346 | | - | |
| 389 | + | |
| 390 | + | |
347 | 391 | | |
348 | 392 | | |
349 | 393 | | |
| |||
402 | 446 | | |
403 | 447 | | |
404 | 448 | | |
405 | | - | |
| 449 | + | |
406 | 450 | | |
407 | 451 | | |
408 | 452 | | |
409 | 453 | | |
410 | | - | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
411 | 457 | | |
412 | 458 | | |
413 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments