Add huerotate option to image

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 4 years ago
parent 9fb6664a63
commit 2b07fc39b2
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -270,7 +270,7 @@ Hide a section (including subsections) in the TOC
#[toc-hidden] Section
Set the size of an image
!(url)[width = 42%, height=auto, grayscale, brightness=10, contrast=1.2, invert]
!(url)[width = 42%, height=auto, brightness=10, contrast=1.2, huerotate=180, invert, grayscale]
Set the source of a quote
[author=Me date=[[date]] display="{{author}} - {{date}}"]> It's me

@ -72,6 +72,7 @@ pub struct PendingImage {
pub mime: Mime,
brightness: Option<i32>,
contrast: Option<f32>,
huerotate: Option<i32>,
grayscale: bool,
invert: bool,
}
@ -89,6 +90,7 @@ impl PendingImage {
contrast: None,
grayscale: false,
invert: false,
huerotate: None,
}
}
@ -99,6 +101,9 @@ impl PendingImage {
if let Some(contrast) = meta.get_float("contrast") {
self.contrast = Some(contrast as f32);
}
if let Some(huerotate) = meta.get_float("huerotate") {
self.huerotate = Some(huerotate as i32);
}
self.grayscale = meta.get_bool("grayscale");
self.invert = meta.get_bool("invert");
}
@ -156,9 +161,15 @@ impl PendingImage {
if let Some(contrast) = self.contrast {
image = image.adjust_contrast(contrast);
}
if let Some(rotate) = self.huerotate {
image = image.huerotate(rotate);
}
if self.grayscale {
image = image.grayscale();
}
if self.invert {
image.invert();
}
@ -198,13 +209,16 @@ impl PendingImage {
let type_name = format!("{:?}", target_format);
if let Some(target_size) = target_size {
file_name += &*format!("-{}-{}", target_size.0, target_size.1);
file_name += &*format!("-w{}-h{}", target_size.0, target_size.1);
}
if let Some(b) = self.brightness {
file_name += &*format!("-{}", b);
file_name += &*format!("-b{}", b);
}
if let Some(c) = self.contrast {
file_name += &*format!("-{}", c);
file_name += &*format!("-c{}", c);
}
if let Some(h) = self.huerotate {
file_name += &*format!("-h{}", h);
}
file_name += &*format!("{}-{}", self.invert, self.grayscale);

Loading…
Cancel
Save