Remove /photo endpoint

This commit is contained in:
Joscha 2025-03-01 22:44:09 +01:00
parent 2451bb3d76
commit d32be913fd
7 changed files with 34 additions and 113 deletions

View file

@ -1,4 +1,6 @@
{
"title": "Moon",
"caption": "(on the moon)",
"algo": "stucki",
"bright": false,
"seamless": false,

View file

@ -3,17 +3,25 @@
#let data = json("data.json")
#let dithered = lib.dither(
#show: it => if data.seamless {
set page(margin: 0pt)
it
} else { it }
#if data.title != none {
align(center, text(size: 32pt, data.title))
}
#lib.dither(
read("image.png", encoding: none),
bright: data.bright,
algorithm: data.algo,
)
#if data.seamless {
set page(margin: 0pt)
dithered
if data.feed { lib.feed }
} else {
dithered
if data.feed { lib.feed }
#if data.caption != none {
align(center, text(size: 32pt, data.caption))
}
#if data.feed {
lib.feed
}

View file

@ -16,6 +16,8 @@ use crate::{
#[derive(Serialize)]
struct Data {
title: Option<String>,
caption: Option<String>,
algo: String,
bright: bool,
seamless: bool,
@ -25,6 +27,8 @@ struct Data {
pub async fn post(server: State<Server>, mut multipart: Multipart) -> somehow::Result<Response> {
let mut image = None;
let mut data = Data {
title: None,
caption: None,
algo: "stucki".to_string(),
bright: true,
seamless: false,
@ -38,6 +42,12 @@ pub async fn post(server: State<Server>, mut multipart: Multipart) -> somehow::R
let decoded = image::load_from_memory(&data)?.into_rgba8();
image = Some(decoded);
}
Some("title") => {
data.title = Some(field.text().await?);
}
Some("caption") => {
data.caption = Some(field.text().await?);
}
Some("algo") => {
data.algo = field.text().await?;
}