@queenanya/baileys 7.2.8 → 7.2.9
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.
|
@@ -24,11 +24,12 @@ export declare const encodeBase64EncodedStringForUpload: (b64: string) => string
|
|
|
24
24
|
export declare const generateProfilePicture: (mediaUpload: WAMediaUpload) => Promise<{
|
|
25
25
|
img: Buffer;
|
|
26
26
|
}>;
|
|
27
|
-
export declare const generateProfilePictureFull: (
|
|
28
|
-
img:
|
|
27
|
+
export declare const generateProfilePictureFull: (img: any) => Promise<{
|
|
28
|
+
img: any;
|
|
29
29
|
}>;
|
|
30
|
-
export declare const generateProfilePictureFP: (
|
|
31
|
-
img:
|
|
30
|
+
export declare const generateProfilePictureFP: (buffer: any) => Promise<{
|
|
31
|
+
img: any;
|
|
32
|
+
preview: any;
|
|
32
33
|
}>;
|
|
33
34
|
export declare const generatePP: (buffer: any) => Promise<{
|
|
34
35
|
img: any;
|
|
@@ -185,83 +185,38 @@ const generateProfilePicture = async (mediaUpload) => {
|
|
|
185
185
|
};
|
|
186
186
|
};
|
|
187
187
|
exports.generateProfilePicture = generateProfilePicture;
|
|
188
|
-
const generateProfilePictureFull = async (
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
else {
|
|
198
|
-
bufferOrFilePath = await (0, exports.toBuffer)(mediaUpload.stream);
|
|
199
|
-
}
|
|
200
|
-
const lib = await getImageProcessingLibrary();
|
|
201
|
-
let img;
|
|
202
|
-
if ('sharp' in lib && typeof ((_a = lib.sharp) === null || _a === void 0 ? void 0 : _a.default) === 'function') {
|
|
203
|
-
img = lib.sharp.default(bufferOrFilePath)
|
|
204
|
-
.resize(720, 720)
|
|
205
|
-
.jpeg({
|
|
206
|
-
quality: 50,
|
|
207
|
-
})
|
|
208
|
-
.toBuffer();
|
|
209
|
-
}
|
|
210
|
-
else if ('jimp' in lib && typeof ((_b = lib.jimp) === null || _b === void 0 ? void 0 : _b.read) === 'function') {
|
|
211
|
-
const { read, MIME_JPEG, RESIZE_BILINEAR } = lib.jimp;
|
|
212
|
-
const jimp = await read(bufferOrFilePath);
|
|
213
|
-
const min = Math.min(jimp.getWidth(), jimp.getHeight());
|
|
214
|
-
const cropped = jimp.crop(0, 0, min, min);
|
|
215
|
-
img = cropped
|
|
216
|
-
.quality(50)
|
|
217
|
-
.resize(720, 720, RESIZE_BILINEAR)
|
|
218
|
-
.getBufferAsync(MIME_JPEG);
|
|
188
|
+
const generateProfilePictureFull = async (img) => {
|
|
189
|
+
const Jimp = require('jimp');
|
|
190
|
+
const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
|
|
191
|
+
const jimp = await read(img);
|
|
192
|
+
const min = Math.min(jimp.getWidth(), jimp.getHeight());
|
|
193
|
+
const cropped = jimp.crop(0, 0, jimp.getWidth(), jimp.getHeight());
|
|
194
|
+
let width = jimp.getWidth(), hight = jimp.getHeight(), ratio;
|
|
195
|
+
if (width > hight) {
|
|
196
|
+
ratio = jimp.getWidth() / 1280;
|
|
219
197
|
}
|
|
220
198
|
else {
|
|
221
|
-
|
|
199
|
+
ratio = jimp.getWidth() / 1280;
|
|
222
200
|
}
|
|
201
|
+
;
|
|
202
|
+
width = width / ratio;
|
|
203
|
+
hight = hight / ratio;
|
|
204
|
+
img = cropped.quality(100).resize(width, hight).getBufferAsync(MIME_JPEG);
|
|
223
205
|
return {
|
|
224
|
-
img: await img
|
|
206
|
+
img: await img
|
|
225
207
|
};
|
|
226
208
|
};
|
|
227
209
|
exports.generateProfilePictureFull = generateProfilePictureFull;
|
|
228
|
-
const generateProfilePictureFP = async (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
bufferOrFilePath = mediaUpload.url.toString();
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
bufferOrFilePath = await (0, exports.toBuffer)(mediaUpload.stream);
|
|
239
|
-
}
|
|
240
|
-
const lib = await getImageProcessingLibrary();
|
|
241
|
-
let img;
|
|
242
|
-
if ('sharp' in lib && typeof ((_a = lib.sharp) === null || _a === void 0 ? void 0 : _a.default) === 'function') {
|
|
243
|
-
img = lib.sharp.default(bufferOrFilePath)
|
|
244
|
-
.resize(1280, 1280)
|
|
245
|
-
.jpeg({
|
|
246
|
-
quality: 50,
|
|
247
|
-
})
|
|
248
|
-
.toBuffer();
|
|
249
|
-
}
|
|
250
|
-
else if ('jimp' in lib && typeof ((_b = lib.jimp) === null || _b === void 0 ? void 0 : _b.read) === 'function') {
|
|
251
|
-
const { read, MIME_JPEG, RESIZE_BILINEAR } = lib.jimp;
|
|
252
|
-
const jimp = await read(bufferOrFilePath);
|
|
253
|
-
const min = Math.min(jimp.getWidth(), jimp.getHeight());
|
|
254
|
-
const cropped = jimp.crop(0, 0, min, min);
|
|
255
|
-
img = cropped
|
|
256
|
-
.quality(50)
|
|
257
|
-
.resize(1280, 1280, RESIZE_BILINEAR)
|
|
258
|
-
.getBufferAsync(MIME_JPEG);
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
throw new boom_1.Boom('No image processing library available');
|
|
262
|
-
}
|
|
210
|
+
const generateProfilePictureFP = async (buffer) => {
|
|
211
|
+
const Jimp = require('jimp');
|
|
212
|
+
const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
|
|
213
|
+
const jimp = await Jimp.read(buffer);
|
|
214
|
+
const min = jimp.getWidth();
|
|
215
|
+
const max = jimp.getHeight();
|
|
216
|
+
const cropped = jimp.crop(0, 0, min, max);
|
|
263
217
|
return {
|
|
264
|
-
img: await
|
|
218
|
+
img: await cropped.scaleToFit(1280, 1280).getBufferAsync(Jimp.MIME_JPEG),
|
|
219
|
+
preview: await cropped.normalize().getBufferAsync(Jimp.MIME_JPEG),
|
|
265
220
|
};
|
|
266
221
|
};
|
|
267
222
|
exports.generateProfilePictureFP = generateProfilePictureFP;
|