Spaces:
Paused
Paused
Commit ·
35e0c5e
1
Parent(s): ad10d01
frontend gif debug
Browse files- index.html +55 -53
index.html
CHANGED
|
@@ -475,6 +475,61 @@
|
|
| 475 |
|
| 476 |
console.log('Processing', totalImages, 'images for GIF');
|
| 477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
imageDataArray.forEach((imageData, index) => {
|
| 479 |
console.log('Loading image', index + 1, 'of', totalImages);
|
| 480 |
const img = new Image();
|
|
@@ -538,59 +593,6 @@
|
|
| 538 |
|
| 539 |
firstImg.src = `data:image/png;base64,${imageDataArray[0]}`;
|
| 540 |
|
| 541 |
-
function startGifRender() {
|
| 542 |
-
console.log('Starting GIF render process');
|
| 543 |
-
container.innerHTML = '<p>Rendering animated GIF...</p>';
|
| 544 |
-
|
| 545 |
-
gif.on('start', function() {
|
| 546 |
-
console.log('GIF rendering started');
|
| 547 |
-
});
|
| 548 |
-
|
| 549 |
-
gif.on('progress', function(p) {
|
| 550 |
-
console.log('GIF rendering progress:', Math.round(p * 100) + '%');
|
| 551 |
-
container.innerHTML = '<p>Rendering animated GIF... ' + Math.round(p * 100) + '%</p>';
|
| 552 |
-
});
|
| 553 |
-
|
| 554 |
-
gif.on('finished', function(blob) {
|
| 555 |
-
console.log('GIF rendering finished, blob size:', blob.size, 'bytes');
|
| 556 |
-
try {
|
| 557 |
-
const url = URL.createObjectURL(blob);
|
| 558 |
-
const gifImg = document.createElement('img');
|
| 559 |
-
gifImg.src = url;
|
| 560 |
-
gifImg.className = 'generated-image';
|
| 561 |
-
gifImg.alt = 'Generated animated GIF';
|
| 562 |
-
|
| 563 |
-
container.innerHTML = '';
|
| 564 |
-
container.appendChild(gifImg);
|
| 565 |
-
console.log('GIF successfully displayed');
|
| 566 |
-
} catch (displayError) {
|
| 567 |
-
console.error('Error displaying GIF:', displayError);
|
| 568 |
-
showMultipleImages(imageDataArray, container);
|
| 569 |
-
}
|
| 570 |
-
});
|
| 571 |
-
|
| 572 |
-
gif.on('abort', function() {
|
| 573 |
-
console.error('GIF rendering was aborted');
|
| 574 |
-
showMultipleImages(imageDataArray, container);
|
| 575 |
-
});
|
| 576 |
-
|
| 577 |
-
// Set another timeout for the rendering process
|
| 578 |
-
const renderTimeout = setTimeout(() => {
|
| 579 |
-
console.error('GIF rendering timeout after 60 seconds');
|
| 580 |
-
gif.abort();
|
| 581 |
-
showMultipleImages(imageDataArray, container);
|
| 582 |
-
}, 60000);
|
| 583 |
-
|
| 584 |
-
gif.on('finished', function() {
|
| 585 |
-
clearTimeout(renderTimeout);
|
| 586 |
-
});
|
| 587 |
-
|
| 588 |
-
gif.on('abort', function() {
|
| 589 |
-
clearTimeout(renderTimeout);
|
| 590 |
-
});
|
| 591 |
-
|
| 592 |
-
gif.render();
|
| 593 |
-
}
|
| 594 |
|
| 595 |
} catch (error) {
|
| 596 |
console.error('Error creating GIF:', error);
|
|
|
|
| 475 |
|
| 476 |
console.log('Processing', totalImages, 'images for GIF');
|
| 477 |
|
| 478 |
+
// Define startGifRender function with access to gif variable
|
| 479 |
+
function startGifRender() {
|
| 480 |
+
console.log('Starting GIF render process');
|
| 481 |
+
container.innerHTML = '<p>Rendering animated GIF...</p>';
|
| 482 |
+
|
| 483 |
+
gif.on('start', function() {
|
| 484 |
+
console.log('GIF rendering started');
|
| 485 |
+
});
|
| 486 |
+
|
| 487 |
+
gif.on('progress', function(p) {
|
| 488 |
+
console.log('GIF rendering progress:', Math.round(p * 100) + '%');
|
| 489 |
+
container.innerHTML = '<p>Rendering animated GIF... ' + Math.round(p * 100) + '%</p>';
|
| 490 |
+
});
|
| 491 |
+
|
| 492 |
+
gif.on('finished', function(blob) {
|
| 493 |
+
console.log('GIF rendering finished, blob size:', blob.size, 'bytes');
|
| 494 |
+
try {
|
| 495 |
+
const url = URL.createObjectURL(blob);
|
| 496 |
+
const gifImg = document.createElement('img');
|
| 497 |
+
gifImg.src = url;
|
| 498 |
+
gifImg.className = 'generated-image';
|
| 499 |
+
gifImg.alt = 'Generated animated GIF';
|
| 500 |
+
|
| 501 |
+
container.innerHTML = '';
|
| 502 |
+
container.appendChild(gifImg);
|
| 503 |
+
console.log('GIF successfully displayed');
|
| 504 |
+
} catch (displayError) {
|
| 505 |
+
console.error('Error displaying GIF:', displayError);
|
| 506 |
+
showMultipleImages(imageDataArray, container);
|
| 507 |
+
}
|
| 508 |
+
});
|
| 509 |
+
|
| 510 |
+
gif.on('abort', function() {
|
| 511 |
+
console.error('GIF rendering was aborted');
|
| 512 |
+
showMultipleImages(imageDataArray, container);
|
| 513 |
+
});
|
| 514 |
+
|
| 515 |
+
// Set another timeout for the rendering process
|
| 516 |
+
const renderTimeout = setTimeout(() => {
|
| 517 |
+
console.error('GIF rendering timeout after 60 seconds');
|
| 518 |
+
gif.abort();
|
| 519 |
+
showMultipleImages(imageDataArray, container);
|
| 520 |
+
}, 60000);
|
| 521 |
+
|
| 522 |
+
gif.on('finished', function() {
|
| 523 |
+
clearTimeout(renderTimeout);
|
| 524 |
+
});
|
| 525 |
+
|
| 526 |
+
gif.on('abort', function() {
|
| 527 |
+
clearTimeout(renderTimeout);
|
| 528 |
+
});
|
| 529 |
+
|
| 530 |
+
gif.render();
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
imageDataArray.forEach((imageData, index) => {
|
| 534 |
console.log('Loading image', index + 1, 'of', totalImages);
|
| 535 |
const img = new Image();
|
|
|
|
| 593 |
|
| 594 |
firstImg.src = `data:image/png;base64,${imageDataArray[0]}`;
|
| 595 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 596 |
|
| 597 |
} catch (error) {
|
| 598 |
console.error('Error creating GIF:', error);
|