@gudhub/ssg-web-components-library 1.0.88 → 1.0.89
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.
package/package.json
CHANGED
|
@@ -117,29 +117,33 @@ class AiImageGenerator extends GHComponent {
|
|
|
117
117
|
downloadLatestBlobImage() {
|
|
118
118
|
const imageAfter = document.getElementById("image-after");
|
|
119
119
|
const imgElement = imageAfter.querySelector("img");
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
if (!imgElement || !imgElement.src.startsWith("blob:")) {
|
|
122
122
|
console.error("No blob image found to download.");
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
|
|
126
|
+
const canvas = document.createElement("canvas");
|
|
127
|
+
const ctx = canvas.getContext("2d");
|
|
128
|
+
|
|
129
|
+
const img = new Image();
|
|
130
|
+
img.crossOrigin = "anonymous";
|
|
131
|
+
img.onload = () => {
|
|
132
|
+
canvas.width = img.width;
|
|
133
|
+
canvas.height = img.height;
|
|
134
|
+
ctx.drawImage(img, 0, 0);
|
|
135
|
+
|
|
136
|
+
canvas.toBlob((blob) => {
|
|
137
|
+
const link = document.createElement("a");
|
|
138
|
+
link.href = URL.createObjectURL(blob);
|
|
139
|
+
link.download = "downloaded-image.jpg";
|
|
140
|
+
document.body.appendChild(link);
|
|
141
|
+
link.click();
|
|
142
|
+
document.body.removeChild(link);
|
|
143
|
+
URL.revokeObjectURL(link.href);
|
|
144
|
+
}, "image/jpeg", 1);
|
|
145
|
+
};
|
|
146
|
+
img.src = imgElement.src;
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
createBlobImageElement(blob) {
|