Export jpeg at 95 quality
This commit is contained in:
parent
b139ce4c98
commit
57f79fe556
|
|
@ -29,6 +29,12 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anyhow"
|
||||||
|
version = "1.0.55"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
|
|
@ -641,6 +647,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"simplelog",
|
"simplelog",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
|
"turbojpeg",
|
||||||
"webbrowser",
|
"webbrowser",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -932,6 +939,26 @@ dependencies = [
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror"
|
||||||
|
version = "1.0.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror-impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror-impl"
|
||||||
|
version = "1.0.30"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tiff"
|
name = "tiff"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
|
|
@ -959,6 +986,28 @@ version = "0.6.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3e5d7cd7ab3e47dda6e56542f4bbf3824c15234958c6e1bd6aaa347e93499fdc"
|
checksum = "3e5d7cd7ab3e47dda6e56542f4bbf3824c15234958c6e1bd6aaa347e93499fdc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "turbojpeg"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "111671fdf720903270c8c19fd641048793a4f8f69abc184e4e7ea9228619c65e"
|
||||||
|
dependencies = [
|
||||||
|
"image",
|
||||||
|
"libc",
|
||||||
|
"thiserror",
|
||||||
|
"turbojpeg-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "turbojpeg-sys"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "03ee42589a950ef4f0f03752c3878676ffe6ab5a468132784ba483b0efc257e6"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-linebreak"
|
name = "unicode-linebreak"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ simplelog = "0.11"
|
||||||
fltk = "1.2"
|
fltk = "1.2"
|
||||||
fltk-theme = "0.4"
|
fltk-theme = "0.4"
|
||||||
image = "0.23"
|
image = "0.23"
|
||||||
|
turbojpeg = { version = "^0.2", features = ["image"] }
|
||||||
imageproc = "0.22"
|
imageproc = "0.22"
|
||||||
rusttype = "0.9"
|
rusttype = "0.9"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ impl ConfigWindow {
|
||||||
let mut label = Frame::default().with_label("Ratio of size of text:");
|
let mut label = Frame::default().with_label("Ratio of size of text:");
|
||||||
label.set_label_font(enums::Font::HelveticaBold);
|
label.set_label_font(enums::Font::HelveticaBold);
|
||||||
col.set_size(&label, 15);
|
col.set_size(&label, 15);
|
||||||
let mut hint = Frame::default().with_label("Font size in image of resolution 4000x5000");
|
let mut hint = Frame::default().with_label("Font size in image of height 4000 pixels");
|
||||||
hint.set_label_font(Font::CourierItalic);
|
hint.set_label_font(Font::CourierItalic);
|
||||||
hint.set_label_size(12);
|
hint.set_label_size(12);
|
||||||
col.set_size(&hint, 20);
|
col.set_size(&hint, 20);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate simplelog;
|
extern crate simplelog;
|
||||||
|
|
||||||
mod about;
|
mod about_window;
|
||||||
mod config;
|
mod config;
|
||||||
mod config_picker;
|
mod config_picker;
|
||||||
mod config_window;
|
mod config_window;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//! Main window where you do all editing
|
//! Main window where you do all editing
|
||||||
use crate::about::About;
|
use crate::about_window::About;
|
||||||
use crate::crop_window::CropWindow;
|
use crate::crop_window::CropWindow;
|
||||||
use crate::draw_thread::*;
|
use crate::draw_thread::*;
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
|
|
|
||||||
19
src/utils.rs
19
src/utils.rs
|
|
@ -192,7 +192,7 @@ impl ImageContainer {
|
||||||
let path_properties = path_original.with_extension("prop");
|
let path_properties = path_original.with_extension("prop");
|
||||||
let export = path_original.parent().unwrap().join("export").join(
|
let export = path_original.parent().unwrap().join("export").join(
|
||||||
path_original
|
path_original
|
||||||
.with_extension("png")
|
.with_extension("jpg")
|
||||||
.file_name()
|
.file_name()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
|
|
@ -236,9 +236,18 @@ impl ImageContainer {
|
||||||
prop.original_dimension.1,
|
prop.original_dimension.1,
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Err(e) = img.save_with_format(&export, image::ImageFormat::Png) {
|
let comp = match turbojpeg::compress_image(&img.into_rgb8(), 95, turbojpeg::Subsamp::None) {
|
||||||
dialog::alert_default("Failed to export png!");
|
Ok(a) => a,
|
||||||
warn!("Failed to export png!\n{:?}", e);
|
Err(e) => {
|
||||||
|
dialog::alert_default("Failed to compress jpeg!");
|
||||||
|
warn!("Failed to compress jpeg!\n{:?}", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(e) = std::fs::write(&export, comp) {
|
||||||
|
dialog::alert_default("Failed to export Image!");
|
||||||
|
warn!("Failed to export Image!\n{:?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,7 +299,7 @@ impl ImageContainer {
|
||||||
let path_properties = path_original.with_extension("prop");
|
let path_properties = path_original.with_extension("prop");
|
||||||
let export = path_original.parent().unwrap().join("export").join(
|
let export = path_original.parent().unwrap().join("export").join(
|
||||||
path_original
|
path_original
|
||||||
.with_extension("png")
|
.with_extension("jpg")
|
||||||
.file_name()
|
.file_name()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue