@xuda.io/ai_module 1.1.4441 → 1.1.4443

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.
Files changed (2) hide show
  1. package/index.mjs +26 -5
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -3020,6 +3020,7 @@ const upload_agent_files = async function (uid, agent_doc) {
3020
3020
  },
3021
3021
  ],
3022
3022
  metadata: { agent_id: agent_doc._id, func: 'upload_agent_files' },
3023
+ account_profile_info,
3023
3024
  });
3024
3025
  if (ret.code < 0) {
3025
3026
  throw new Error('something went wrong try again later');
@@ -6321,6 +6322,7 @@ const attachment_handler = async function (uid, app_id, conversation_id, attachm
6321
6322
  },
6322
6323
  ],
6323
6324
  metadata: { conversation_id, func: 'attachment_handler' },
6325
+ account_profile_info,
6324
6326
  });
6325
6327
 
6326
6328
  return ret;
@@ -6546,22 +6548,41 @@ export const get_profile_picture = async function (uid, account_type = 'business
6546
6548
  }
6547
6549
  };
6548
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
+
6549
6569
  async function normalizeBase64To1024(base64Image) {
6550
6570
  const inputBuffer = Buffer.from(base64Image, 'base64');
6551
6571
 
6552
6572
  const normalizedBuffer = await sharp(inputBuffer)
6553
6573
  .resize(1024, 1024, {
6554
- fit: 'contain', // Preserve aspect ratio, fit within 211x211
6555
- background: { r: 0, g: 0, b: 0, alpha: 0 }, // Transparent background for padding
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
6556
6577
  })
6557
6578
  .png({
6558
- quality: 100,
6559
- compressionLevel: 9,
6579
+ quality: 98,
6580
+ compressionLevel: 8,
6560
6581
  force: true,
6561
6582
  })
6562
6583
  .toBuffer();
6563
6584
 
6564
- return normalizedBuffer.toString('base64'); // Return normalized base64 string
6585
+ return normalizedBuffer.toString('base64');
6565
6586
  }
6566
6587
 
6567
6588
  const get_image_blob_from_downloaded_image = async function (url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4441",
3
+ "version": "1.1.4443",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",