@xuda.io/ai_module 1.1.4442 → 1.1.4444
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 +25 -6
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4356,7 +4356,7 @@ const chat_email = async function (req, job_id, headers) {
|
|
|
4356
4356
|
|
|
4357
4357
|
const sender_app_id = account_profile_info.app_id;
|
|
4358
4358
|
let sender_conversation_doc = await db_module.get_app_couch_doc_native(sender_app_id, conversation_id);
|
|
4359
|
-
|
|
4359
|
+
debugger;
|
|
4360
4360
|
await attachment_handler(uid, sender_app_id, conversation_id, attachments, account_profile_info);
|
|
4361
4361
|
|
|
4362
4362
|
const item = await client.conversations.items.create(conversation_id, {
|
|
@@ -6548,22 +6548,41 @@ export const get_profile_picture = async function (uid, account_type = 'business
|
|
|
6548
6548
|
}
|
|
6549
6549
|
};
|
|
6550
6550
|
|
|
6551
|
+
// async function normalizeBase64To1024(base64Image) {
|
|
6552
|
+
// const inputBuffer = Buffer.from(base64Image, 'base64');
|
|
6553
|
+
|
|
6554
|
+
// const normalizedBuffer = await sharp(inputBuffer)
|
|
6555
|
+
// .resize(1024, 1024, {
|
|
6556
|
+
// fit: 'contain', // Preserve aspect ratio, fit within 211x211
|
|
6557
|
+
// background: { r: 0, g: 0, b: 0, alpha: 0 }, // Transparent background for padding
|
|
6558
|
+
// })
|
|
6559
|
+
// .png({
|
|
6560
|
+
// quality: 100,
|
|
6561
|
+
// compressionLevel: 9,
|
|
6562
|
+
// force: true,
|
|
6563
|
+
// })
|
|
6564
|
+
// .toBuffer();
|
|
6565
|
+
|
|
6566
|
+
// return normalizedBuffer.toString('base64'); // Return normalized base64 string
|
|
6567
|
+
// }
|
|
6568
|
+
|
|
6551
6569
|
async function normalizeBase64To1024(base64Image) {
|
|
6552
6570
|
const inputBuffer = Buffer.from(base64Image, 'base64');
|
|
6553
6571
|
|
|
6554
6572
|
const normalizedBuffer = await sharp(inputBuffer)
|
|
6555
6573
|
.resize(1024, 1024, {
|
|
6556
|
-
fit: '
|
|
6557
|
-
|
|
6574
|
+
fit: 'inside', // Scale up/down to fit inside 1024×1024 while preserving aspect ratio
|
|
6575
|
+
withoutEnlargement: false, // Allow enlargement if original is smaller
|
|
6576
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 }, // Still transparent padding
|
|
6558
6577
|
})
|
|
6559
6578
|
.png({
|
|
6560
|
-
quality:
|
|
6561
|
-
compressionLevel:
|
|
6579
|
+
quality: 98,
|
|
6580
|
+
compressionLevel: 8,
|
|
6562
6581
|
force: true,
|
|
6563
6582
|
})
|
|
6564
6583
|
.toBuffer();
|
|
6565
6584
|
|
|
6566
|
-
return normalizedBuffer.toString('base64');
|
|
6585
|
+
return normalizedBuffer.toString('base64');
|
|
6567
6586
|
}
|
|
6568
6587
|
|
|
6569
6588
|
const get_image_blob_from_downloaded_image = async function (url) {
|