28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { json } from "@sveltejs/kit";
|
|
import type { RequestHandler } from "./$types";
|
|
import { putObject } from "$lib/helpers/minio";
|
|
import { generateImage } from "$lib/helpers/stability";
|
|
|
|
export const GET: RequestHandler = async ({ params }) => {
|
|
|
|
const inputName = params.name;
|
|
|
|
const prompt = `realistic profile portrait oil painting of a masked ${inputName}, baroque, Charles Vess, masked ball attire, Charles Vess, opulence, mystery, elegance, medium-length blond hair, darker skin`;
|
|
const negativePrompt = "blurry, multiple persons, picture frame"
|
|
|
|
const a = performance.now()
|
|
const image = await generateImage(prompt, negativePrompt);
|
|
const duration = performance.now() - a;
|
|
|
|
console.log({ duration })
|
|
|
|
const imageName = `${image.seed}-${inputName.toLowerCase().split(" ").slice(0, 5).join("-").slice(0, 25)}.png`
|
|
|
|
const res = await putObject(imageName, Buffer.from(image.base64, 'base64'), { "Content-Type": "image/png" });
|
|
|
|
return json({
|
|
...res,
|
|
url: `https://s3.app.max-richter.dev/silvester23/${imageName}`
|
|
})
|
|
}
|