mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix extractImageThumb threw with webpack (#2266)
* fix extractImageThumb threw with webpack * Update messages-media.ts * Update src/Utils/messages-media.ts * fix: typescript errors Co-authored-by: Adhiraj Singh <adhirajsingh1001@gmail.com>
This commit is contained in:
@@ -96,7 +96,7 @@ export const extractImageThumb = async(bufferOrFilePath: Readable | Buffer | str
|
||||
}
|
||||
|
||||
const lib = await getImageProcessingLibrary()
|
||||
if('sharp' in lib) {
|
||||
if('sharp' in lib && lib.sharp?.default) {
|
||||
const img = lib.sharp!.default(bufferOrFilePath)
|
||||
const dimensions = await img.metadata()
|
||||
|
||||
@@ -111,7 +111,7 @@ export const extractImageThumb = async(bufferOrFilePath: Readable | Buffer | str
|
||||
height: dimensions.height,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
} else if('jimp' in lib && lib.jimp) {
|
||||
const { read, MIME_JPEG, RESIZE_BILINEAR, AUTO } = lib.jimp
|
||||
|
||||
const jimp = await read(bufferOrFilePath as any)
|
||||
@@ -127,6 +127,8 @@ export const extractImageThumb = async(bufferOrFilePath: Readable | Buffer | str
|
||||
buffer,
|
||||
original: dimensions
|
||||
}
|
||||
} else {
|
||||
throw new Boom('No image processing library available')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user