feat: convert all to jpg

This commit is contained in:
2023-11-13 02:53:21 +01:00
parent 355c195c27
commit 72a60f1da5
6 changed files with 623 additions and 10 deletions

View File

@ -1,4 +1,5 @@
import { json } from "@sveltejs/kit";
import * as Jimp from "jimp";
import type { RequestHandler } from "./$types";
import { putObject } from "$lib/helpers/minio";
import { generateImage } from "$lib/helpers/stability";
@ -33,6 +34,11 @@ export const POST: RequestHandler = async ({ params, request }) => {
await putObject(imageName, Buffer.from(image.base64, 'base64'), { "Content-Type": "image/png" });
const img = await Jimp.read(Buffer.from(image.base64, "base64"));
const jpgBuffer = await img.quality(70).getBufferAsync(Jimp.MIME_JPEG);
await putObject(imageName.replace(".png", ".jpg"), jpgBuffer, { "Content-Type": "image/jpeg" });
return json({
duration,
url: `https://s3-api.app.max-richter.dev/silvester23/${imageName}`