i add der shtuff
This commit is contained in:
commit
86d5ba45c9
4 changed files with 1315 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
1244
Cargo.lock
generated
Normal file
1244
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "megafarp"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
clap = { version = "4.3.19", features = ["derive"] }
|
||||||
|
png = "0.11.0"
|
||||||
|
reqwest = { version = "0.11.18", features = ["blocking"] }
|
59
src/main.rs
Normal file
59
src/main.rs
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
use std::io::Write;
|
||||||
|
use std::fs::File;
|
||||||
|
use reqwest::header::USER_AGENT;
|
||||||
|
use std::io::BufWriter;
|
||||||
|
use std::path::Path;
|
||||||
|
use png::HasParameters;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
// megafarp, a program for farping 128x64 1 bit PNG images onto furpsocial.
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[clap(author, version, about, long_about = None)]
|
||||||
|
struct Args {
|
||||||
|
/// Name of PNG file to take as input to farp.
|
||||||
|
#[clap(short, long)]
|
||||||
|
input: String,
|
||||||
|
|
||||||
|
/// Signature to use in the farp.
|
||||||
|
#[clap(short, long, default_value = "megafarp")]
|
||||||
|
signature: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args = Args::parse();
|
||||||
|
derp(args.input, args.signature);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn derp(input: String, sig: String) {
|
||||||
|
let decoder = png::Decoder::new(File::open(input).unwrap());
|
||||||
|
let (info ,mut reader) = decoder.read_info().unwrap();
|
||||||
|
let mut buf = vec![0; info.buffer_size()];
|
||||||
|
reader.next_frame(&mut buf).unwrap();
|
||||||
|
let mut luf = vec![];
|
||||||
|
let mut i: usize = 0;
|
||||||
|
while i < buf.len() {
|
||||||
|
if buf[i] > 127 { luf.push(0); }
|
||||||
|
else { luf.push(1); }
|
||||||
|
i = i + 3;
|
||||||
|
}
|
||||||
|
let mut w = String::new();
|
||||||
|
i = 0;
|
||||||
|
let mut x: usize = 0;
|
||||||
|
for v in luf {
|
||||||
|
if w == String::new() { w = format!("{}", v); }
|
||||||
|
else { w = format!("{}{}", w, v); }
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut params = HashMap::new();
|
||||||
|
params.insert("image-bits", w.clone());
|
||||||
|
params.insert("signature",sig);
|
||||||
|
|
||||||
|
let headers = format!("image-bits={}&signature=megafarp", w);
|
||||||
|
let client = reqwest::blocking::Client::new();
|
||||||
|
let res = client.post("https://furp.colean.cc/farp.php")
|
||||||
|
.form(¶ms)
|
||||||
|
.header(USER_AGENT, "megafarp/0.1.0 (https://git.colean.cc/threeoh6000/megafarp)")
|
||||||
|
.send();
|
||||||
|
}
|
Reference in a new issue