@queenanya/baileys 8.3.4 → 8.3.5

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.
@@ -1,3 +1,4 @@
1
+ import { WAMediaUpload } from '../Types';
1
2
  export declare const generateProfilePictureFull: (img: any) => Promise<{
2
3
  img: Buffer<ArrayBufferLike>;
3
4
  }>;
@@ -9,6 +10,9 @@ export declare const generatePP: (buffer: any) => Promise<{
9
10
  img: Buffer<ArrayBufferLike>;
10
11
  preview: Buffer<ArrayBufferLike>;
11
12
  }>;
13
+ export declare const generateProfilePicturee: (mediaUpload: WAMediaUpload) => Promise<{
14
+ img: Buffer<ArrayBufferLike>;
15
+ }>;
12
16
  export declare const changeprofileFull: (img: any) => Promise<{
13
17
  img: any;
14
18
  }>;
@@ -3,9 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.changeprofileFull = exports.generatePP = exports.generateProfilePictureFP = exports.generateProfilePictureFull = void 0;
6
+ exports.changeprofileFull = exports.generateProfilePicturee = exports.generatePP = exports.generateProfilePictureFP = exports.generateProfilePictureFull = void 0;
7
7
  const jimp_1 = __importDefault(require("jimp"));
8
8
  const jimp_2 = require("jimp");
9
+ const toBuffer = async (stream) => {
10
+ const chunks = [];
11
+ for await (const chunk of stream) {
12
+ chunks.push(chunk);
13
+ }
14
+ stream.destroy();
15
+ return Buffer.concat(chunks);
16
+ };
9
17
  const generateProfilePictureFull = async (img) => {
10
18
  const jimp = await (0, jimp_2.read)(img);
11
19
  const min = Math.min(jimp.getWidth(), jimp.getHeight());
@@ -48,6 +56,28 @@ const generatePP = async (buffer) => {
48
56
  };
49
57
  };
50
58
  exports.generatePP = generatePP;
59
+ const generateProfilePicturee = async (mediaUpload) => {
60
+ let bufferOrFilePath;
61
+ let img;
62
+ if (Buffer.isBuffer(mediaUpload)) {
63
+ bufferOrFilePath = mediaUpload;
64
+ }
65
+ else if ('url' in mediaUpload) {
66
+ bufferOrFilePath = mediaUpload.url.toString();
67
+ }
68
+ else {
69
+ bufferOrFilePath = await toBuffer(mediaUpload.stream);
70
+ }
71
+ const jimp = await jimp_1.default.read(bufferOrFilePath);
72
+ const cropped = jimp.getWidth() > jimp.getHeight() ? jimp.resize(720, -1) : jimp.resize(-1, 720);
73
+ img = cropped
74
+ .quality(100)
75
+ .getBufferAsync(jimp_1.default.MIME_JPEG);
76
+ return {
77
+ img: await img,
78
+ };
79
+ };
80
+ exports.generateProfilePicturee = generateProfilePicturee;
51
81
  const changeprofileFull = async (img) => {
52
82
  const Jimp = require('jimp');
53
83
  const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
@@ -14,7 +14,7 @@ const updateProfilePictureFull = async (jid, content, sock) => {
14
14
  if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
15
15
  targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
16
16
  }
17
- const { img } = await (0, media_messages_1.generateProfilePictureFull)(content);
17
+ const { img } = await (0, media_messages_1.generateProfilePictureFP)(content);
18
18
  await query({
19
19
  tag: 'iq',
20
20
  attrs: {
@@ -42,7 +42,7 @@ const updateProfilePictureFull2 = async (jid, content, sock) => {
42
42
  if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
43
43
  targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
44
44
  }
45
- const { preview } = await (0, media_messages_1.generateProfilePictureFP)(content);
45
+ const { preview } = await (0, media_messages_1.generatePP)(content);
46
46
  await query({
47
47
  tag: 'iq',
48
48
  attrs: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@queenanya/baileys",
3
- "version": "8.3.4",
3
+ "version": "8.3.5",
4
4
  "description": "Custom Baileys WhatsApp API",
5
5
  "keywords": [
6
6
  "baileys",