diff --git a/Cargo.lock b/Cargo.lock index fa00185..8ef9db2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,6 +29,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "anyhow" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd" + [[package]] name = "atty" version = "0.2.14" @@ -641,6 +647,7 @@ dependencies = [ "serde_json", "simplelog", "textwrap", + "turbojpeg", "webbrowser", ] @@ -932,6 +939,26 @@ dependencies = [ "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]] name = "tiff" version = "0.6.1" @@ -959,6 +986,28 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" 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]] name = "unicode-linebreak" version = "0.1.2" diff --git a/Cargo.toml b/Cargo.toml index 57c072d..9426818 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ simplelog = "0.11" fltk = "1.2" fltk-theme = "0.4" image = "0.23" +turbojpeg = { version = "^0.2", features = ["image"] } imageproc = "0.22" rusttype = "0.9" serde_json = "1.0" diff --git a/src/about.rs b/src/about_window.rs similarity index 100% rename from src/about.rs rename to src/about_window.rs diff --git a/src/config_window.rs b/src/config_window.rs index d503cae..908d909 100644 --- a/src/config_window.rs +++ b/src/config_window.rs @@ -188,7 +188,7 @@ impl ConfigWindow { let mut label = Frame::default().with_label("Ratio of size of text:"); label.set_label_font(enums::Font::HelveticaBold); 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_size(12); col.set_size(&hint, 20); diff --git a/src/main.rs b/src/main.rs index afb98c2..a1b481e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ extern crate log; extern crate simplelog; -mod about; +mod about_window; mod config; mod config_picker; mod config_window; diff --git a/src/main_window.rs b/src/main_window.rs index 19549b0..c47ea85 100644 --- a/src/main_window.rs +++ b/src/main_window.rs @@ -13,7 +13,7 @@ */ //! Main window where you do all editing -use crate::about::About; +use crate::about_window::About; use crate::crop_window::CropWindow; use crate::draw_thread::*; use crate::utils; diff --git a/src/utils.rs b/src/utils.rs index d882a65..cccf5f0 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -192,7 +192,7 @@ impl ImageContainer { let path_properties = path_original.with_extension("prop"); let export = path_original.parent().unwrap().join("export").join( path_original - .with_extension("png") + .with_extension("jpg") .file_name() .unwrap() .to_str() @@ -236,9 +236,18 @@ impl ImageContainer { prop.original_dimension.1, ); - if let Err(e) = img.save_with_format(&export, image::ImageFormat::Png) { - dialog::alert_default("Failed to export png!"); - warn!("Failed to export png!\n{:?}", e); + let comp = match turbojpeg::compress_image(&img.into_rgb8(), 95, turbojpeg::Subsamp::None) { + Ok(a) => a, + 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 export = path_original.parent().unwrap().join("export").join( path_original - .with_extension("png") + .with_extension("jpg") .file_name() .unwrap() .to_str()