Compare commits
No commits in common. "022dbec73e60fff230e5b322125471956462e203" and "69288185c1d5afbfd04d4e9a88acf23edd5b98f4" have entirely different histories.
022dbec73e
...
69288185c1
4 changed files with 54 additions and 118 deletions
21
LICENSE
21
LICENSE
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2024 endernon
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
5
log.txt
5
log.txt
|
@ -1,5 +0,0 @@
|
||||||
input path DIR
|
|
||||||
Filepath: "/new2/git/wynn-pack-temp/assets/minecraft/textures/colormap/foliage.png"
|
|
||||||
Dimensions: (256, 256)
|
|
||||||
Colorspace: RGB
|
|
||||||
BitDepth: Eight
|
|
30
readme.md
30
readme.md
|
@ -1,30 +0,0 @@
|
||||||
# respack-decrypter
|
|
||||||
|
|
||||||
This tool allows you to unfuck corrupted images in a resource pack that have been corrupted to be protected.
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
- download the Rust-Lang for your system
|
|
||||||
- download this repository
|
|
||||||
- run `cargo build --release` in the directory
|
|
||||||
- check `./target/release`
|
|
||||||
- run `respack-decrypter` if you are on linux/mac (RUN `chmod +x respack-decrypter` ON IT FIRST)
|
|
||||||
- run `respack-decrypter.exe` if you are on windows
|
|
||||||
|
|
||||||
# syntax
|
|
||||||
|
|
||||||
Check `--help` for syntax or `-h` for shortened explanation
|
|
||||||
|
|
||||||
# I want some logs for checking wtf is happening
|
|
||||||
|
|
||||||
Pipe your output to a new filename.
|
|
||||||
|
|
||||||
Note: It might not work for SOME linux shells. But major ones e.g. `zsh`,`bash` support it.
|
|
||||||
|
|
||||||
`respack-decrypter --path ~/somedir/ --debug > ~/log.txt`
|
|
||||||
|
|
||||||
# License
|
|
||||||
|
|
||||||
It's all MIT, except the example corrupted inventory.png which is courtesy of Wynncraft.
|
|
||||||
|
|
||||||
Zeer you better not come after me for this one, you still haven't answered my gdpr req yet
|
|
114
src/main.rs
114
src/main.rs
|
@ -1,83 +1,83 @@
|
||||||
|
use image::ImageBuffer;
|
||||||
|
use zune_png::{zune_core::options::DecoderOptions, PngDecoder};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use glob::glob;
|
use glob::glob;
|
||||||
use image::ImageBuffer;
|
use std::fs::metadata;
|
||||||
use std::io::{BufReader, Read};
|
use std::path::{Path, PathBuf};
|
||||||
use std::{
|
|
||||||
fs::{metadata, File},
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
};
|
|
||||||
use zune_png::{zune_core::options::DecoderOptions, PngDecoder};
|
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Input path
|
/// Input path
|
||||||
///
|
|
||||||
/// Include a file path or a directory path. Do not use any asterisks or wildcards.
|
|
||||||
/// If the path includes spaces you may find it useful to use speechmarks (" ") around the path.
|
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
path: PathBuf,
|
path: Vec<PathBuf>,
|
||||||
|
|
||||||
|
/// Output path
|
||||||
|
#[arg(short, long)]
|
||||||
|
out: Option<PathBuf>,
|
||||||
|
|
||||||
// /// Output path
|
|
||||||
// #[arg(short, long,default_value="")]
|
|
||||||
// out: PathBuf,
|
|
||||||
/// Debug mode
|
/// Debug mode
|
||||||
///
|
#[arg(short, long, default_value_t=false)]
|
||||||
/// Either "true" or "false"
|
|
||||||
#[arg(short, long, default_value_t = false)]
|
|
||||||
debug: bool,
|
debug: bool,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
// argument parsing yep
|
// argument parsing yep
|
||||||
let Args: Args = Args::parse();
|
let Args: Args = Args::parse();
|
||||||
let pathfr = Args.path.clone();
|
let pathfr = Args.path.clone();
|
||||||
let debugmode = Args.debug;
|
let outfr = match Args.out {
|
||||||
|
Some(realoutpath) => {
|
||||||
|
realoutpath
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
Args.path
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let realdebugmode = Args.debug;
|
||||||
|
|
||||||
|
let mut filelist: Vec<String> = Vec::new();
|
||||||
|
|
||||||
let mut filelist: Vec<PathBuf> = Vec::new();
|
|
||||||
|
|
||||||
let pathtype = metadata(&pathfr).unwrap();
|
let pathtype = metadata(&pathfr).unwrap();
|
||||||
if pathtype.is_file() {
|
if pathtype.is_file() {
|
||||||
filelist.push(PathBuf::from(format!("{:?}", pathtype)));
|
|
||||||
println!("input path FILE");
|
|
||||||
} else if pathtype.is_dir() {
|
|
||||||
println!("input path DIR");
|
|
||||||
// parse file list if it's a dir
|
|
||||||
for entry in glob(&format!("{}/**/*.png", pathfr.clone().display()))
|
|
||||||
.expect("Failed to read glob pattern (you should panic)")
|
|
||||||
{
|
|
||||||
match entry {
|
|
||||||
Ok(path) => {
|
|
||||||
// println!("{:?}", path.display());
|
|
||||||
filelist.push(path.display().to_string().parse().unwrap());
|
|
||||||
}
|
}
|
||||||
Err(e) => {
|
// else if pathtype.is_dir() {
|
||||||
println!("Shell globbing error");
|
// // parse file list if it's a dir
|
||||||
|
// for entry in glob(&format!("{}/**/*.png", pathfr.clone().display())).expect("Failed to read glob pattern (you should panic)") {
|
||||||
|
// match entry {
|
||||||
|
// Ok(path) => {
|
||||||
|
// // println!("{:?}", path.display());
|
||||||
|
// filelist.push(path.display().to_string());
|
||||||
|
// },
|
||||||
|
// Err(e) => {
|
||||||
|
// println!("Shell globbing error");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// panic!("")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
if realdebugmode {
|
||||||
|
for i in filelist {
|
||||||
|
println!("{i}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
panic!("that input is neither file nor dir and thats scary...")
|
|
||||||
}
|
|
||||||
|
|
||||||
// if debugmode {
|
|
||||||
// for i in filelist.clone() {
|
|
||||||
// println!("List of files: {}",i.display())
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
for thatpath in filelist {
|
let data = include_bytes!("../inventory.png");
|
||||||
encoder(thatpath, debugmode)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn encoder(filepath: PathBuf, modeDebug: bool) {
|
|
||||||
let file = File::open(&filepath).unwrap();
|
|
||||||
let mut data = BufReader::new(file);
|
|
||||||
let mut buf = Vec::new();
|
|
||||||
data.read_to_end(&mut buf).unwrap();
|
|
||||||
|
|
||||||
let mut decoder = PngDecoder::new_with_options(buf, DecoderOptions::new_cmd());
|
|
||||||
|
|
||||||
|
let mut decoder = PngDecoder::new_with_options(data, DecoderOptions::new_cmd());
|
||||||
|
|
||||||
decoder.decode_headers().unwrap();
|
decoder.decode_headers().unwrap();
|
||||||
let dim = decoder.get_dimensions().unwrap();
|
let dim = decoder.get_dimensions().unwrap();
|
||||||
//dbg!(dim);
|
//dbg!(dim);
|
||||||
|
@ -87,18 +87,10 @@ fn encoder(filepath: PathBuf, modeDebug: bool) {
|
||||||
//dbg!(&data);
|
//dbg!(&data);
|
||||||
let depth = decoder.get_depth().unwrap();
|
let depth = decoder.get_depth().unwrap();
|
||||||
|
|
||||||
if modeDebug {
|
|
||||||
println!("Filepath: {:?}", filepath);
|
|
||||||
println!("Dimensions: {:?}", dim);
|
|
||||||
println!("Colorspace: {:?}", col);
|
|
||||||
println!("BitDepth: {:?}", depth);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: figure out propper color checks rn we assume data is RGBA
|
// TODO: figure out propper color checks rn we assume data is RGBA
|
||||||
|
|
||||||
let out: ImageBuffer<image::Rgba<u8>, Vec<u8>> =
|
let out: ImageBuffer<image::Rgba<u8>, Vec<u8>> =
|
||||||
ImageBuffer::from_raw(dim.0 as u32, dim.1 as u32, data).unwrap();
|
ImageBuffer::from_raw(dim.0 as u32, dim.1 as u32, data).unwrap();
|
||||||
|
|
||||||
out.save(filepath.clone()).unwrap();
|
out.save("out.png").unwrap();
|
||||||
println!("wrote file {:?}\n",filepath)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue