@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/ssg-web-components-library",
3
- "version": "1.0.88",
3
+ "version": "1.0.89",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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
- fetch(imgElement.src)
127
- .then(response => response.blob())
128
- .then(blob => {
129
- const objectUrl = URL.createObjectURL(blob);
130
-
131
- const link = document.createElement("a");
132
- link.href = objectUrl;
133
- link.download = "downloaded-image.png";
134
- document.body.appendChild(link);
135
- link.click();
136
-
137
- document.body.removeChild(link);
138
- URL.revokeObjectURL(objectUrl);
139
- })
140
- .catch(err => {
141
- console.error("Failed to download image:", err);
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) {