add: lossy encode webp images
This commit is contained in:
parent
03480d32db
commit
24162573ee
8 changed files with 145 additions and 437 deletions
|
@ -1,6 +1,5 @@
|
|||
use axum::{extract::Path, response::IntoResponse, Extension, Json};
|
||||
use axum_extra::extract::CookieJar;
|
||||
use image::ImageFormat;
|
||||
use tetratto_core::model::{
|
||||
communities::Post,
|
||||
permissions::FinePermission,
|
||||
|
@ -9,7 +8,7 @@ use tetratto_core::model::{
|
|||
};
|
||||
use crate::{
|
||||
get_user_from_token,
|
||||
image::{save_buffer, JsonMultipart},
|
||||
image::{save_webp_buffer, JsonMultipart},
|
||||
routes::api::v1::{CreatePost, CreateRepost, UpdatePostContent, UpdatePostContext},
|
||||
State,
|
||||
};
|
||||
|
@ -109,11 +108,8 @@ pub async fn create_request(
|
|||
Err(e) => return Json(e.into()),
|
||||
};
|
||||
|
||||
if let Err(e) = save_buffer(
|
||||
&upload.path(&data.0).to_string(),
|
||||
image.to_vec(),
|
||||
ImageFormat::WebP,
|
||||
) {
|
||||
if let Err(e) = save_webp_buffer(&upload.path(&data.0).to_string(), image.to_vec())
|
||||
{
|
||||
return Json(Error::MiscError(e.to_string()).into());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue