1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use serde::{Deserialize, Serialize};
use caesura_macros::Options;
use caesura_options::{OptionRule, OptionsContract};
/// Options for image resizing
#[derive(Options, Clone, Debug, Deserialize, Serialize)]
pub struct FileOptions {
/// Should compression of images be disabled?
#[arg(long)]
pub no_image_compression: bool,
/// Should transcoded files be renamed?
///
/// If enabled then tracks are renamed into a standardized format: `{number} {title}.{ext}`.
///
/// Multi-disc releases will be organized into `CD1/`, `CD2/` subfolders.
///
/// - `1 Example track title.flac`
/// - `CD1/10 Example track title.mp3`
#[arg(long)]
pub rename_tracks: bool,
/// Maximum file size in bytes beyond which images are compressed.
///
/// Only applies to image files.
#[arg(long)]
#[options(default = 750_000)]
pub max_file_size: u64,
/// Maximum size in pixels for images.
///
/// Only applied if the image is greater than `max_file_size`.
#[arg(long)]
#[options(default = 1280)]
pub max_pixel_size: u32,
/// Quality percentage to apply for jpg compression.
///
/// Only applied if the image is greater than `max_file_size`.
#[arg(long)]
#[options(default = 80)]
pub jpg_quality: u8,
/// Should conversion of png images to jpg be disabled?
///
/// Only applied if the image is greater than `max_file_size`.
#[arg(long)]
pub no_png_to_jpg: bool,
}
impl FileOptions {
/// Default maximum file size in bytes beyond which images are compressed.
pub const DEFAULT_MAX_FILE_SIZE: u64 = 750_000;
/// Default maximum size in pixels for images.
pub const DEFAULT_MAX_PIXEL_SIZE: u32 = 1280;
/// Default quality percentage for JPG compression.
pub const DEFAULT_JPG_QUALITY: u8 = 80;
}
impl OptionsContract for FileOptions {
type Partial = FileOptionsPartial;
fn validate(&self, _errors: &mut Vec<OptionRule>) {}
}