mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-12-22 19:31:35 +00:00
Add control over gif frame count
This commit is contained in:
parent
88ca9793e8
commit
4cc810d372
6 changed files with 17 additions and 3 deletions
|
@ -39,6 +39,7 @@ cache_duration = 168
|
||||||
max_width = 128
|
max_width = 128
|
||||||
max_height = 128
|
max_height = 128
|
||||||
max_area = 16384
|
max_area = 16384
|
||||||
|
max_frame_count = 100
|
||||||
|
|
||||||
[repo]
|
[repo]
|
||||||
type = "sled"
|
type = "sled"
|
||||||
|
|
|
@ -224,6 +224,14 @@ max_height = 128
|
||||||
# depending on whether video uploads are enabled
|
# depending on whether video uploads are enabled
|
||||||
max_area = 16384
|
max_area = 16384
|
||||||
|
|
||||||
|
# Optional: Maximum number of frames permitted in uploaded gifs
|
||||||
|
# environment variable: PICTRS__MEDIA__GIF__MAX_FRAME_COUNT
|
||||||
|
# default: 100
|
||||||
|
#
|
||||||
|
# If a gif does not fit within this bound, it will either be transcoded to a video or rejected,
|
||||||
|
# depending on whether video uploads are enabled
|
||||||
|
max_frame_count = 100
|
||||||
|
|
||||||
|
|
||||||
## Database configuration
|
## Database configuration
|
||||||
[repo]
|
[repo]
|
||||||
|
|
|
@ -462,19 +462,19 @@ struct Run {
|
||||||
media_max_frame_count: Option<usize>,
|
media_max_frame_count: Option<usize>,
|
||||||
/// Maximum width allowed for gif uploads.
|
/// Maximum width allowed for gif uploads.
|
||||||
///
|
///
|
||||||
/// If an upload exceeds this value, it will be transcoded to a video format or aborted,
|
/// If an upload exceeds this value, it will be transcoded to a video format or rejected,
|
||||||
/// depending on whether video uploads are enabled.
|
/// depending on whether video uploads are enabled.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
media_gif_max_width: Option<usize>,
|
media_gif_max_width: Option<usize>,
|
||||||
/// Maximum height allowed for gif uploads
|
/// Maximum height allowed for gif uploads
|
||||||
///
|
///
|
||||||
/// If an upload exceeds this value, it will be transcoded to a video format or aborted,
|
/// If an upload exceeds this value, it will be transcoded to a video format or rejected,
|
||||||
/// depending on whether video uploads are enabled.
|
/// depending on whether video uploads are enabled.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
media_gif_max_height: Option<usize>,
|
media_gif_max_height: Option<usize>,
|
||||||
/// Maximum area allowed for gif uploads
|
/// Maximum area allowed for gif uploads
|
||||||
///
|
///
|
||||||
/// If an upload exceeds this value, it will be transcoded to a video format or aborted,
|
/// If an upload exceeds this value, it will be transcoded to a video format or rejected,
|
||||||
/// depending on whether video uploads are enabled.
|
/// depending on whether video uploads are enabled.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
media_gif_max_area: Option<usize>,
|
media_gif_max_area: Option<usize>,
|
||||||
|
|
|
@ -81,6 +81,7 @@ struct GifDefaults {
|
||||||
max_height: usize,
|
max_height: usize,
|
||||||
max_width: usize,
|
max_width: usize,
|
||||||
max_area: usize,
|
max_area: usize,
|
||||||
|
max_frame_count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, serde::Serialize)]
|
#[derive(Clone, Debug, serde::Serialize)]
|
||||||
|
@ -187,6 +188,7 @@ impl Default for GifDefaults {
|
||||||
max_height: 128,
|
max_height: 128,
|
||||||
max_width: 128,
|
max_width: 128,
|
||||||
max_area: 16384,
|
max_area: 16384,
|
||||||
|
max_frame_count: 100,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,8 @@ pub(crate) struct Gif {
|
||||||
pub(crate) max_height: usize,
|
pub(crate) max_height: usize,
|
||||||
|
|
||||||
pub(crate) max_area: usize,
|
pub(crate) max_area: usize,
|
||||||
|
|
||||||
|
pub(crate) max_frame_count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Media {
|
impl Media {
|
||||||
|
|
|
@ -33,6 +33,7 @@ impl TranscodeOptions {
|
||||||
if details.width <= media.gif.max_width
|
if details.width <= media.gif.max_width
|
||||||
&& details.height <= media.gif.max_height
|
&& details.height <= media.gif.max_height
|
||||||
&& details.width * details.height <= media.gif.max_area
|
&& details.width * details.height <= media.gif.max_area
|
||||||
|
&& details.frames.unwrap_or(1) <= media.gif.max_frame_count
|
||||||
{
|
{
|
||||||
return Self {
|
return Self {
|
||||||
input_format,
|
input_format,
|
||||||
|
|
Loading…
Reference in a new issue