mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
switched from sharp to jimp for img processing
This commit is contained in:
@@ -32,16 +32,15 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"curve25519-js": "0.0.4",
|
"curve25519-js": "0.0.4",
|
||||||
"futoin-hkdf": "^1.3.2",
|
"futoin-hkdf": "^1.3.2",
|
||||||
|
"jimp": "^0.14.0",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"protobufjs": "^6.9.0",
|
"protobufjs": "^6.9.0",
|
||||||
"qrcode-terminal": "^0.12.0",
|
"qrcode-terminal": "^0.12.0",
|
||||||
"sharp": "^0.25.4",
|
|
||||||
"ws": "^7.3.0"
|
"ws": "^7.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/mocha": "^7.0.2",
|
"@types/mocha": "^7.0.2",
|
||||||
"@types/node": "^14.0.14",
|
"@types/node": "^14.0.14",
|
||||||
"@types/sharp": "^0.25.0",
|
|
||||||
"@types/ws": "^7.2.6",
|
"@types/ws": "^7.2.6",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.5.0",
|
"@typescript-eslint/eslint-plugin": "^3.5.0",
|
||||||
"@typescript-eslint/parser": "^3.5.0",
|
"@typescript-eslint/parser": "^3.5.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { MessageType, HKDFInfoKeys, MessageOptions, WAMessageType } from './Constants'
|
import { MessageType, HKDFInfoKeys, MessageOptions, WAMessageType } from './Constants'
|
||||||
import sharp from 'sharp'
|
import Jimp from 'jimp'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
import { WAMessage, WAMessageContent } from '../WAConnection/Constants'
|
import { WAMessage, WAMessageContent } from '../WAConnection/Constants'
|
||||||
@@ -60,8 +60,10 @@ const extractVideoThumb = async (
|
|||||||
})
|
})
|
||||||
}) as Promise<void>
|
}) as Promise<void>
|
||||||
|
|
||||||
export const compressImage = async (buffer: Buffer) => sharp(buffer).resize(48, 48).jpeg().toBuffer()
|
export const compressImage = async (buffer: Buffer) => {
|
||||||
|
const jimp = await Jimp.read (buffer)
|
||||||
|
return jimp.resize(48, 48).getBufferAsync (Jimp.MIME_JPEG)
|
||||||
|
}
|
||||||
/** generates a thumbnail for a given media, if required */
|
/** generates a thumbnail for a given media, if required */
|
||||||
export async function generateThumbnail(buffer: Buffer, mediaType: MessageType, info: MessageOptions) {
|
export async function generateThumbnail(buffer: Buffer, mediaType: MessageType, info: MessageOptions) {
|
||||||
if (info.thumbnail === null || info.thumbnail) {
|
if (info.thumbnail === null || info.thumbnail) {
|
||||||
|
|||||||
Reference in New Issue
Block a user