| 277 | * @returns {Promise<Buffer>} Processed image buffer | 277 | * @returns {Promise<Buffer>} Processed image buffer |
| 278 | */ | 278 | */ |
| 279 | export async function applyAvatarCropResize(jimp, crop) { | 279 | export async function applyAvatarCropResize(jimp, crop) { |
| 280 | const image = /** @type {InstanceType<typeof import('../jimp.js').Jimp>} */ (jimp); | 280 | if (!(jimp instanceof Jimp)) { |
| | 281 | throw new TypeError('Expected a Jimp instance'); |
| | 282 | } |
| | 283 | |
| | 284 | const image = /** @type {InstanceType<typeof Jimp>} */ (jimp); |
| 281 | let finalWidth = image.bitmap.width, finalHeight = image.bitmap.height; | 285 | let finalWidth = image.bitmap.width, finalHeight = image.bitmap.height; |
| 282 | | 286 | |
| 283 | // Apply crop if defined | 287 | // Apply crop if defined |