8 lines
218 B
TypeScript
8 lines
218 B
TypeScript
|
import sharp from "sharp";
|
||
|
|
||
|
export async function ensureJpg(avatar: Buffer) {
|
||
|
const img = await sharp(avatar).toFormat("jpeg").resize(512, 512);
|
||
|
const buf = await img.toBuffer();
|
||
|
return buf.toString("base64");
|
||
|
}
|