Skip to content

Commit

Permalink
improved logging
Browse files Browse the repository at this point in the history
improved logging (increased performance)
  • Loading branch information
PatriikPlays committed May 28, 2023
1 parent 2d597b9 commit 8fc7f05
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "img2poster"
version = "0.0.4"
version = "0.0.6"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
23 changes: 14 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,24 +273,20 @@ fn main() {
} else {
let mut pixels: Vec<Color> = Vec::with_capacity((block_size * block_size) as usize);

print!("Parsing image... ");
for y in 0..y_size {
for x in 0..x_size {
let pixel = unwrapped_image.get_pixel(x, y);

let rgb = pixel.to_rgb();
pixels.push(Color::new(rgb[0], rgb[1], rgb[2], 255));
}

println!(
"Parsing image: {0}% complete",
f32::min(
100 as f32,
f32::max(0 as f32, (y as f32) / (y_size as f32)) * (100 as f32)
)
);
}
println!("Done");

print!("Quantizing and dithering image... ");
let (dithered_pixels, color_palette) = dither(pixels, x_size as usize);
println!("Done");

for block_y in 0..y_size / block_size {
for block_x in 0..x_size / block_size {
Expand Down Expand Up @@ -352,9 +348,18 @@ fn main() {
let json = serde_json::to_string(&poster).unwrap();
posters.push(json.as_str().to_string());
}

println!(
"Splitting image into posters: {0}% complete",
f32::min(
100 as f32,
f32::max(0 as f32, block_y as f32 / ((y_size / block_size) as f32)) * (100 as f32)
)
);
}
println!("Splitting image into posters: 100% complete");
}
println!("100% complete");
println!("Done, saving to file");

let mut out_path = output.clone();
if posters.len() > 1 {
Expand Down

0 comments on commit 8fc7f05

Please sign in to comment.