mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-05-13 13:17:45 +00:00
fix: resize custom images
This commit is contained in:
parent
e078d59812
commit
e47914f873
3 changed files with 3 additions and 3 deletions
|
|
@ -163,7 +163,7 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
images.map(async (image, index) => {
|
images.map(async (image, index) => {
|
||||||
const buffer = Buffer.from(await image.arrayBuffer());
|
const buffer = Buffer.from(await image.arrayBuffer());
|
||||||
const pngBuffer = await sharp(buffer).png({ quality: 85 }).toBuffer();
|
const pngBuffer = await sharp(buffer).resize({ height: 800, fit: "inside", withoutEnlargement: true }).png({ quality: 85 }).toBuffer();
|
||||||
const fileLocation = path.join(miiUploadsDirectory, `image${index}.png`);
|
const fileLocation = path.join(miiUploadsDirectory, `image${index}.png`);
|
||||||
|
|
||||||
await fs.writeFile(fileLocation, pngBuffer);
|
await fs.writeFile(fileLocation, pngBuffer);
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,7 @@ export async function POST(request: NextRequest) {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
customImages.map(async (image, index) => {
|
customImages.map(async (image, index) => {
|
||||||
const buffer = Buffer.from(await image.arrayBuffer());
|
const buffer = Buffer.from(await image.arrayBuffer());
|
||||||
const pngBuffer = await sharp(buffer).png({ quality: 85 }).toBuffer();
|
const pngBuffer = await sharp(buffer).resize({ height: 800, fit: "inside", withoutEnlargement: true }).png({ quality: 85 }).toBuffer();
|
||||||
const fileLocation = path.join(miiUploadsDirectory, `image${index}.png`);
|
const fileLocation = path.join(miiUploadsDirectory, `image${index}.png`);
|
||||||
|
|
||||||
await fs.writeFile(fileLocation, pngBuffer);
|
await fs.writeFile(fileLocation, pngBuffer);
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ export default async function MiiList({ searchParams, userId, inLikesPage }: Pro
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MiiGrid miis={miis} />
|
<MiiGrid miis={miis} userId={userId} />
|
||||||
<Pagination lastPage={lastPage} />
|
<Pagination lastPage={lastPage} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue