Crop minimum limiy while loading image
This commit is contained in:
parent
efcf7eae1d
commit
6f39a8209a
14
src/utils.rs
14
src/utils.rs
|
|
@ -118,6 +118,12 @@ impl ImageContainer {
|
||||||
let img = load_image(&image_info);
|
let img = load_image(&image_info);
|
||||||
let (width, height): (f64, f64) = Coord::from(img.dimensions()).into();
|
let (width, height): (f64, f64) = Coord::from(img.dimensions()).into();
|
||||||
|
|
||||||
|
let (crop_width, _) = croped_ratio(width, height);
|
||||||
|
println!("{} {}", crop_width, globals::CONFIG.read().unwrap().minimum_width_limit);
|
||||||
|
if crop_width < globals::CONFIG.read().unwrap().minimum_width_limit {
|
||||||
|
show_alert("Image width is below limit");
|
||||||
|
}
|
||||||
|
|
||||||
let config = globals::CONFIG.read().unwrap();
|
let config = globals::CONFIG.read().unwrap();
|
||||||
let mut prop = properties.write().unwrap();
|
let mut prop = properties.write().unwrap();
|
||||||
prop.image_info = Some(image_info.to_owned());
|
prop.image_info = Some(image_info.to_owned());
|
||||||
|
|
@ -154,10 +160,6 @@ impl ImageContainer {
|
||||||
let (origina_crop_width, origina_crop_height) =
|
let (origina_crop_width, origina_crop_height) =
|
||||||
croped_ratio(original_width, original_height);
|
croped_ratio(original_width, original_height);
|
||||||
|
|
||||||
if origina_crop_width < globals::CONFIG.read().unwrap().minimum_width_limit {
|
|
||||||
show_alert("Image width is below limit");
|
|
||||||
}
|
|
||||||
|
|
||||||
prop.crop_position = Some((
|
prop.crop_position = Some((
|
||||||
(original_width - origina_crop_width) / 2.0,
|
(original_width - origina_crop_width) / 2.0,
|
||||||
(original_height - origina_crop_height) / 2.0,
|
(original_height - origina_crop_height) / 2.0,
|
||||||
|
|
@ -183,10 +185,6 @@ impl ImageContainer {
|
||||||
let (s_width, s_height): (f64, f64) = Coord::from(self.image.dimensions()).into();
|
let (s_width, s_height): (f64, f64) = Coord::from(self.image.dimensions()).into();
|
||||||
let (c_width, c_height) = croped_ratio(s_width, s_height);
|
let (c_width, c_height) = croped_ratio(s_width, s_height);
|
||||||
|
|
||||||
if c_width < globals::CONFIG.read().unwrap().minimum_width_limit {
|
|
||||||
show_alert("Image width is below limit");
|
|
||||||
}
|
|
||||||
|
|
||||||
let (cx, cy) = (
|
let (cx, cy) = (
|
||||||
(original_x * s_width) / original_width,
|
(original_x * s_width) / original_width,
|
||||||
(original_y * s_height) / original_height,
|
(original_y * s_height) / original_height,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue