mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-03-28 11:13:16 +00:00
feat: resize portrait and features image
This commit is contained in:
parent
d0f32333e9
commit
4f03d611eb
1 changed files with 16 additions and 2 deletions
|
|
@ -235,14 +235,28 @@ export async function POST(request: NextRequest) {
|
|||
|
||||
// Save features image
|
||||
const featuresBuffer = Buffer.from(await miiFeaturesImage.arrayBuffer());
|
||||
const pngBuffer = await sharp(featuresBuffer).png({ quality: 85 }).toBuffer();
|
||||
const pngBuffer = await sharp(featuresBuffer)
|
||||
.resize({
|
||||
height: 800,
|
||||
fit: "inside",
|
||||
withoutEnlargement: true,
|
||||
})
|
||||
.png({ quality: 85 })
|
||||
.toBuffer();
|
||||
const fileLocation = path.join(miiUploadsDirectory, "features.png");
|
||||
await fs.writeFile(fileLocation, pngBuffer);
|
||||
}
|
||||
|
||||
// Save portrait image
|
||||
if (!portraitBuffer) throw Error("Mii portrait buffer not initialised");
|
||||
const pngBuffer = await sharp(portraitBuffer).png({ quality: 85 }).toBuffer();
|
||||
const pngBuffer = await sharp(portraitBuffer)
|
||||
.resize({
|
||||
height: 500,
|
||||
fit: "inside",
|
||||
withoutEnlargement: true,
|
||||
})
|
||||
.png({ quality: 85 })
|
||||
.toBuffer();
|
||||
const fileLocation = path.join(miiUploadsDirectory, "mii.png");
|
||||
|
||||
await fs.writeFile(fileLocation, pngBuffer);
|
||||
|
|
|
|||
Loading…
Reference in a new issue