@xuda.io/ai_module 1.1.4445 → 1.1.4447
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 +14 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6470,6 +6470,11 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6470
6470
|
prompt = `find "${name}" icon/logo, Return only png,jpg image url single result e.g: "https://example.com/logo_image.png", nothing else`;
|
|
6471
6471
|
factual_prompt = `create logo for the company named: "${name}" the logo should only be initials of the name or geometric shape`;
|
|
6472
6472
|
originalname = normalizeFilename(name) + '_xu_logo.png';
|
|
6473
|
+
resize = {
|
|
6474
|
+
fit: 'cover', // Fill the 1024×1024 area (may crop edges)
|
|
6475
|
+
position: 'centre', // Center the crop
|
|
6476
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
|
6477
|
+
};
|
|
6473
6478
|
break;
|
|
6474
6479
|
}
|
|
6475
6480
|
|
|
@@ -6533,7 +6538,7 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6533
6538
|
background: 'transparent',
|
|
6534
6539
|
});
|
|
6535
6540
|
|
|
6536
|
-
imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json);
|
|
6541
|
+
imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json, resize);
|
|
6537
6542
|
account_module.record_ai_usage(uid, image_response.usage.input_tokens, image_response.usage.output_tokens, 'profile image', prompt, model, { url }, account_profile_info);
|
|
6538
6543
|
}
|
|
6539
6544
|
const outputBuffer = Buffer.from(imageBase64, 'base64');
|
|
@@ -6578,7 +6583,14 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6578
6583
|
// return normalizedBuffer.toString('base64'); // Return normalized base64 string
|
|
6579
6584
|
// }
|
|
6580
6585
|
|
|
6581
|
-
async function normalizeBase64To1024(
|
|
6586
|
+
async function normalizeBase64To1024(
|
|
6587
|
+
base64Image,
|
|
6588
|
+
resize = {
|
|
6589
|
+
fit: 'inside', // Scale up/down to fit inside 1024×1024 while preserving aspect ratio
|
|
6590
|
+
withoutEnlargement: false, // Allow enlargement if original is smaller
|
|
6591
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 }, // Still transparent padding
|
|
6592
|
+
},
|
|
6593
|
+
) {
|
|
6582
6594
|
const inputBuffer = Buffer.from(base64Image, 'base64');
|
|
6583
6595
|
|
|
6584
6596
|
const normalizedBuffer = await sharp(inputBuffer)
|