@xuda.io/ai_module 1.1.4335 → 1.1.4336
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/index.mjs +4 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6775,20 +6775,20 @@ const get_profile_image = async function (uid, account_type = 'business', name,
|
|
|
6775
6775
|
} // throw new Error('not valid url');
|
|
6776
6776
|
let file;
|
|
6777
6777
|
try {
|
|
6778
|
-
file = await
|
|
6778
|
+
file = await get_image_blob_from_downloaded_image(url);
|
|
6779
6779
|
} catch (err) {
|
|
6780
6780
|
if (!err.message.includes('Failed to fetch image URL')) return console.error(err);
|
|
6781
6781
|
|
|
6782
6782
|
try {
|
|
6783
6783
|
url = await get_url();
|
|
6784
|
-
file = await
|
|
6784
|
+
file = await get_image_blob_from_downloaded_image(url);
|
|
6785
6785
|
} catch (err) {
|
|
6786
6786
|
// create factual image
|
|
6787
6787
|
|
|
6788
6788
|
return console.error(err);
|
|
6789
6789
|
}
|
|
6790
6790
|
}
|
|
6791
|
-
// const file = await
|
|
6791
|
+
// const file = await get_image_blob_from_downloaded_image(url);
|
|
6792
6792
|
// const imageBase64 = Buffer.from(await file.image_blob.arrayBuffer()).toString('base64');
|
|
6793
6793
|
const model = 'chatgpt-image-latest';
|
|
6794
6794
|
const prompt = `
|
|
@@ -6846,7 +6846,7 @@ async function normalizeBase64To1024(base64Image) {
|
|
|
6846
6846
|
return normalizedBuffer.toString('base64'); // Return normalized base64 string
|
|
6847
6847
|
}
|
|
6848
6848
|
|
|
6849
|
-
const
|
|
6849
|
+
const get_image_blob_from_downloaded_image = async function (url) {
|
|
6850
6850
|
async function hasTransparentBackground(filePath) {
|
|
6851
6851
|
const image = sharp(filePath);
|
|
6852
6852
|
const metadata = await image.metadata();
|