Files
Checkmate/server/src/utils/imageProcessing.ts
T

18 lines
391 B
TypeScript
Raw Normal View History

2025-04-20 11:29:53 -07:00
import sharp from "sharp";
2026-01-22 21:49:49 +00:00
const GenerateAvatarImage = async (file: Express.Multer.File) => {
2026-03-03 18:26:42 +00:00
// Resize to target 64 * 64
2026-03-03 18:27:42 +00:00
const resizedImageBuffer = await sharp(file.buffer)
2026-03-03 18:26:42 +00:00
.resize({
width: 64,
height: 64,
fit: "cover",
})
.toBuffer();
2025-04-20 11:29:53 -07:00
2026-03-03 18:26:42 +00:00
//Get b64 string
const base64Image = resizedImageBuffer.toString("base64");
return base64Image;
2025-04-20 11:29:53 -07:00
};
export { GenerateAvatarImage };