Update static/index.html
Browse files- static/index.html +5 -5
static/index.html
CHANGED
|
@@ -74,7 +74,6 @@
|
|
| 74 |
const outputImage = document.getElementById('outputImage');
|
| 75 |
|
| 76 |
const canvas = document.createElement('canvas');
|
| 77 |
-
canvas.style.background = 'transparent'; // Set canvas background to transparent
|
| 78 |
const ctx = canvas.getContext('2d');
|
| 79 |
|
| 80 |
const img = new Image();
|
|
@@ -83,28 +82,29 @@
|
|
| 83 |
canvas.height = img.height;
|
| 84 |
|
| 85 |
if (backgroundOption === 'transparent') {
|
| 86 |
-
//
|
| 87 |
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
| 88 |
-
ctx.drawImage(img, 0, 0);
|
| 89 |
} else if (backgroundOption === 'color') {
|
| 90 |
// Fill canvas with color background
|
| 91 |
ctx.fillStyle = colorPicker.value;
|
| 92 |
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 93 |
-
ctx.drawImage(img, 0, 0);
|
| 94 |
} else if (backgroundOption === 'custom') {
|
| 95 |
const file = customBackgroundInput.files[0];
|
| 96 |
if (file) {
|
| 97 |
const bgImg = new Image();
|
| 98 |
bgImg.onload = function() {
|
|
|
|
| 99 |
canvas.width = bgImg.width;
|
| 100 |
canvas.height = bgImg.height;
|
| 101 |
ctx.drawImage(bgImg, 0, 0);
|
| 102 |
-
ctx.drawImage(img, 0, 0);
|
| 103 |
};
|
| 104 |
bgImg.src = URL.createObjectURL(file);
|
| 105 |
}
|
| 106 |
}
|
| 107 |
|
|
|
|
|
|
|
|
|
|
| 108 |
processedImageDataUrl = canvas.toDataURL('image/png');
|
| 109 |
outputImage.src = processedImageDataUrl;
|
| 110 |
};
|
|
|
|
| 74 |
const outputImage = document.getElementById('outputImage');
|
| 75 |
|
| 76 |
const canvas = document.createElement('canvas');
|
|
|
|
| 77 |
const ctx = canvas.getContext('2d');
|
| 78 |
|
| 79 |
const img = new Image();
|
|
|
|
| 82 |
canvas.height = img.height;
|
| 83 |
|
| 84 |
if (backgroundOption === 'transparent') {
|
| 85 |
+
// Clear canvas to make it transparent
|
| 86 |
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
|
| 87 |
} else if (backgroundOption === 'color') {
|
| 88 |
// Fill canvas with color background
|
| 89 |
ctx.fillStyle = colorPicker.value;
|
| 90 |
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
| 91 |
} else if (backgroundOption === 'custom') {
|
| 92 |
const file = customBackgroundInput.files[0];
|
| 93 |
if (file) {
|
| 94 |
const bgImg = new Image();
|
| 95 |
bgImg.onload = function() {
|
| 96 |
+
// Draw custom background image on canvas
|
| 97 |
canvas.width = bgImg.width;
|
| 98 |
canvas.height = bgImg.height;
|
| 99 |
ctx.drawImage(bgImg, 0, 0);
|
|
|
|
| 100 |
};
|
| 101 |
bgImg.src = URL.createObjectURL(file);
|
| 102 |
}
|
| 103 |
}
|
| 104 |
|
| 105 |
+
// Draw processed image on top
|
| 106 |
+
ctx.drawImage(img, 0, 0);
|
| 107 |
+
|
| 108 |
processedImageDataUrl = canvas.toDataURL('image/png');
|
| 109 |
outputImage.src = processedImageDataUrl;
|
| 110 |
};
|