Browse Source

Fixed

master v0.1.1
Unbewohnte 3 years ago
parent
commit
7a16929df8
  1. 2
      Cargo.lock
  2. 2
      Cargo.toml
  3. 7
      src/main.rs

2
Cargo.lock generated

@ -4,4 +4,4 @@ version = 3
[[package]] [[package]]
name = "pngrip" name = "pngrip"
version = "0.1.0" version = "0.1.1"

2
Cargo.toml

@ -1,6 +1,6 @@
[package] [package]
name = "pngrip" name = "pngrip"
version = "0.1.0" version = "0.1.1"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

7
src/main.rs

@ -58,10 +58,13 @@ fn rip_png(path: &Path, destination: &Path) {
let mut start_pos: usize = 0; let mut start_pos: usize = 0;
let mut last_pos: usize = 0; let mut last_pos: usize = 0;
let mut end_pos: usize = 0; let mut end_pos: usize = 0;
for i in 0..file_bytes.len()-png_identifier.len() { for i in 0..file_bytes.len()-iend_identifier.len() {
if i < file_bytes.len() - png_identifier.len() {
if file_bytes[i..i + png_identifier.len()] == png_identifier { if file_bytes[i..i + png_identifier.len()] == png_identifier {
start_pos = i; start_pos = i;
} }
}
if file_bytes[i..i + iend_identifier.len()] == iend_identifier { if file_bytes[i..i + iend_identifier.len()] == iend_identifier {
end_pos = i + iend_identifier.len(); end_pos = i + iend_identifier.len();
@ -70,7 +73,6 @@ fn rip_png(path: &Path, destination: &Path) {
if start_pos < end_pos && start_pos != last_pos { if start_pos < end_pos && start_pos != last_pos {
last_pos = start_pos; last_pos = start_pos;
image_count += 1; image_count += 1;
// println!("[INFO] Found PNG at {}->{} ({} bytes)", start_pos, end_pos, end_pos - start_pos);
let mut ripped_image_file; let mut ripped_image_file;
let ripped_image_filename = format!("{}_{}.png", filename, image_count); let ripped_image_filename = format!("{}_{}.png", filename, image_count);
@ -94,7 +96,6 @@ fn rip_png(path: &Path, destination: &Path) {
} }
} }
println!("[INFO] Ripped {} images from \"{}\" in total", image_count, filename); println!("[INFO] Ripped {} images from \"{}\" in total", image_count, filename);
} }

Loading…
Cancel
Save