@xuda.io/ai_module 1.1.4446 → 1.1.4448
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 +10 -7
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -6538,7 +6538,7 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6538
6538
|
background: 'transparent',
|
|
6539
6539
|
});
|
|
6540
6540
|
|
|
6541
|
-
imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json);
|
|
6541
|
+
imageBase64 = await normalizeBase64To1024(image_response.data[0].b64_json, resize);
|
|
6542
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);
|
|
6543
6543
|
}
|
|
6544
6544
|
const outputBuffer = Buffer.from(imageBase64, 'base64');
|
|
@@ -6583,15 +6583,18 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6583
6583
|
// return normalizedBuffer.toString('base64'); // Return normalized base64 string
|
|
6584
6584
|
// }
|
|
6585
6585
|
|
|
6586
|
-
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
|
+
) {
|
|
6587
6594
|
const inputBuffer = Buffer.from(base64Image, 'base64');
|
|
6588
6595
|
|
|
6589
6596
|
const normalizedBuffer = await sharp(inputBuffer)
|
|
6590
|
-
.resize(1024, 1024,
|
|
6591
|
-
fit: 'inside', // Scale up/down to fit inside 1024×1024 while preserving aspect ratio
|
|
6592
|
-
withoutEnlargement: false, // Allow enlargement if original is smaller
|
|
6593
|
-
background: { r: 0, g: 0, b: 0, alpha: 0 }, // Still transparent padding
|
|
6594
|
-
})
|
|
6597
|
+
.resize(1024, 1024, resize)
|
|
6595
6598
|
.png({
|
|
6596
6599
|
quality: 98,
|
|
6597
6600
|
compressionLevel: 8,
|