Blazingly Rapid Uncompressed Harebrained Image File Format.

Related tags

Command-line bruh
Overview

BRUHIFF

Blazingly rapid uncompressed harebrained Image File Format.

Also known as BRUHIFF or BRUH.

Example

How to

  1. Download the repo / git clone it.

  2. Open a command prompt in the directory / cd bruh

  3. Run cargo run compile followed by a path/to/image.png to compile PNG to BRUH. Example: cargo run compile C:\Uses\User\Downloads\image.png

  4. Run cargo run followed by a path/to/image.bruh to show the image

OR

  1. Double-click on image.bruh using your File Explorer.
  2. Click on More Apps

More Apps

  1. Click on Choose app from this PC

Choose app

Tip: tick "Always use this app to open .bruh files"

  1. Type the path/to/this/project.
  2. Select bruh.exe inside this folder.

That's it! You can now open .bruh files!

Known issues

⚠ The PNG > BRUH won't work unless you have the same file (i.e. image.png) but with the .bruh extension (i.e. image.bruh). What do you have to do? Create an empty file called image.bruh.

  1. Preview window width & height are not exact.
  2. Huge file size on large images.
  3. Slow preview window.
  4. Some large images might include #0 hex which will crash the program.
  5. No transparency.
  6. Only works on Windows
You might also like...
Warp is a blazingly fast, Rust-based terminal that makes you and your team more productive at running, debugging, and deploying code and infrastructure.
Warp is a blazingly fast, Rust-based terminal that makes you and your team more productive at running, debugging, and deploying code and infrastructure.

Warp is a blazingly fast, Rust-based terminal that makes you and your team more productive at running, debugging, and deploying code and infrastructure.

A blazingly fast Insertion Sort and Quick Sort visualizer built with Rust and WASM.
A blazingly fast Insertion Sort and Quick Sort visualizer built with Rust and WASM.

sortysort A blazingly fast Insertion Sort and Quick Sort visualizer built with Rust and WASM. Try it in your browser from here Testing locally cargo r

A blazingly fast command-line tool for converting Chinese punctuations to English punctuations
A blazingly fast command-line tool for converting Chinese punctuations to English punctuations

A blazingly fast command-line tool for converting Chinese punctuations to English punctuations

A robust, customizable, blazingly-fast, efficient and easy-to-use command line application to uwu'ify your text!
A robust, customizable, blazingly-fast, efficient and easy-to-use command line application to uwu'ify your text!

uwuifyy A robust, customizable, blazingly-fast, efficient and easy-to-use command line application to uwu'ify your text! Logo Credits: Jade Nelson Tab

🚀 A blazingly fast easy to use dotfile and global theme manager written in Rust
🚀 A blazingly fast easy to use dotfile and global theme manager written in Rust

GTHEME A blazingly fast easy to use dotfile and global theme manager for *NIX systems written in Rust 🔥 Demo using wip desktop. To check out more des

A CLI calculator written in Rust that isn't blazingly fast.

Calcamabob A command line calculator Is written in Rust Is not blazing fast, and could be faster. Calcamabob can interpret operator precedence. For ex

Bonk - The blazingly fast touch alternative written in rust
Bonk - The blazingly fast touch alternative written in rust

Bonk The blazingly fast touch alternative written in rust. Made for the sole purpose to create files. Explore the docs » View Demo · Report Bug · Requ

Print your git contributions in your terminal, blazingly fast
Print your git contributions in your terminal, blazingly fast

Takoyaki Blazingly fast git contribution graph in your terminal Features ✔️ Customizable ✔️ Plugins to support a bunch of cloud based git repositories

Blazingly fast Rust CLI app to sync data from a folder of excel workbooks into generated c# code for unity usage
Blazingly fast Rust CLI app to sync data from a folder of excel workbooks into generated c# code for unity usage

Extensions supported ( .xls, .xlsx, .xlsm, .xlsb, .xla, .xlam, .ods ) Speed Test Image shows the results of 5000defs synced from 2 workbooks and 5 she

Comments
  • there was some random issue, but i fixed it

    there was some random issue, but i fixed it

    this was the input and output i was getting:

    cargo run compile /Users/nicojaffer/Downloads/102607-funny-kolobanga-png-image-high-quality.png Finished dev [unoptimized + debuginfo] target(s) in 1.46s Running target/debug/bruh compile /Users/nicojaffer/Downloads/102607-funny-kolobanga-png-image-high-quality.png thread 'main' panicked at 'File delete failed: Os { code: 2, kind: NotFound, message: "No such file or directory" }', main.rs:65:40 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

    but i fixed it: heres the updated code (sorry i couldnt upload as file, app github doesnt allow that filetype.) (also this was for the main.rs file)

    #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release

    use eframe::egui; use egui_extras::RetainedImage;

    extern crate css_color_parser;

    use colors_transform::Rgb; use image; use image::GenericImageView; use std::{ env, fs::{self, OpenOptions}, io::Write, path::PathBuf, };

    use skia_safe::{ AlphaType, Color4f, ColorType, EncodedImageFormat, ImageInfo, Paint, Rect, Surface, };

    use css_color_parser::Color as CssColor;

    static TEMP_RESULT_PATH: &str = "temp.png";

    fn vec_to_u32_ne(bytes: &[u8]) -> u32 { let mut result = [0u8; 4]; result.copy_from_slice(bytes); u32::from_ne_bytes(result) }

    fn png_to_bruh(path: PathBuf) -> Result<(), std::io::Error> { let img = image::open(&path).expect("File not found!"); let mut str = String::new(); let mut last_line = 0;

    for pixel in img.pixels() {
        let hex_color = Rgb::from(
            pixel.2 .0[0] as f32,
            pixel.2 .0[1] as f32,
            pixel.2 .0[2] as f32,
        )
        .to_css_hex_string();
    
        if last_line != pixel.1 {
            str.push_str("\n");
            last_line = pixel.1;
        }
        str.push_str(&hex_color.replace("#", ""));
    }
    
    if let Some(path_str) = &path.to_str() {
        let height: u32 = img.height();
        let width: u32 = img.width();
    
        let height_bytes: [u8; 4] = height.to_ne_bytes();
        let width_bytes: [u8; 4] = width.to_ne_bytes();
        let path_to_bruh = path_str.replace(".png", ".bruh");
        // let mut file = fs::File::create(path_str.replace(".png", ".bruh")).expect("Couldn't write to image.bruh");
    
        // file.write_all(&height_bytes);
        // file.write_all(&width_bytes);
    
        // file.write_all(str.as_bytes());
        use std::env;
    

    use std::process::Command;

    fn main() { let path_to_bruh = env::args().nth(1).expect("Missing file path argument");

    let output = Command::new("rm")
        .arg(&path_to_bruh)
        .output()
        .expect("Failed to execute command");
    
    if output.status.success() {
        println!("File deleted successfully");
    } else {
        let error_message = String::from_utf8_lossy(&output.stderr);
        println!("File delete failed: {}", error_message);
    }
    

    }

        let mut file = OpenOptions::new()
            .write(true)
            .create(true)
            .open(path_to_bruh)
            .expect("Couldnt write");
        let string_bytes: Vec<u8> = Vec::from(str.as_bytes());
    
        file.write_all(&width_bytes).unwrap();
        file.write_all(&height_bytes).unwrap();
        file.write_all(&string_bytes).unwrap();
        file.flush().unwrap();
    } else {
        println!("{}", "couldn't find")
    }
    
    Ok(())
    

    }

    fn bruh_to_png(path: PathBuf) -> (u32, u32) { let mut contents: Vec = fs::read(&path).expect("Couldn't read file."); let binding: Vec<_> = contents.drain(0..8).collect();

    let width = vec_to_u32_ne(&binding[0..4]);
    let height = vec_to_u32_ne(&binding[4..8]);
    
    let sanitized_content = String::from_utf8_lossy(&contents).replace("\n", "");
    
    let result: Vec<&str> = sanitized_content
        .as_bytes()
        .chunks(6)
        .map(std::str::from_utf8)
        .collect::<Result<_, _>>()
        .expect("Invalid UTF-8 sequence in the input string");
    
    let info = ImageInfo::new(
        (width as i32, height as i32),
        ColorType::RGBA8888,
        AlphaType::Opaque,
        None,
    );
    
    let mut surface = Surface::new_raster(&info, None, None).unwrap();
    let canvas = surface.canvas();
    
    for (i, color) in result.iter().enumerate() {
        let hex = "#".to_owned() + color;
    
        let parsed_color = hex
            .parse::<CssColor>()
            .expect("Failed to convert Hex to RGB");
        let color4f = Color4f::new(
            parsed_color.r as f32,
            parsed_color.g as f32,
            parsed_color.b as f32,
            0.004 as f32,
        );
        let paint = Paint::new(color4f, None);
        if i == 0 {
            println!("{:?}", paint)
        }
        let x = i % width as usize;
        let y = i / width as usize;
    
        let rect = Rect::from_point_and_size((x as f32, y as f32), (1.0, 1.0));
        canvas.draw_rect(rect, &paint);
    }
    
    let image = surface.image_snapshot();
    
    if let Some(data) = image.encode(None, EncodedImageFormat::PNG, 100) {
        fs::write(TEMP_RESULT_PATH, &*data).expect("Failed to write image data to file");
    }
    
    return (width, height);
    

    }

    fn main() -> Result<(), eframe::Error> { let args: Vec = env::args().collect(); let file_path: PathBuf = (&args[1]).into();

    if &args[1] == "compile" {
        if args.len() < 3 {
            panic!("Secondary argument ('path') not provided. Example: `cargo run compile ~/image.png`")
        }
    
        let path: PathBuf = (&args[2]).into();
    
        match png_to_bruh(path) {
            Ok(()) => println!("{}", "Successfully converted PNG to BRUH"),
            Err(_) => println!("{}", "Failed to convert PNG to BRUH"),
        }
    
        Ok(())
    } else {
        let (width, height) = bruh_to_png(file_path);
        println!("{} {}", width, height);
        let options = eframe::NativeOptions {
            initial_window_size: Some(egui::vec2(width as f32, height as f32)),
            ..Default::default()
        };
    
        eframe::run_native(
            "Image preview",
            options,
            Box::new(|_cc| Box::<ImagePreview>::default()),
        )
    }
    

    } struct ImagePreview { image: RetainedImage, }

    impl Default for ImagePreview { fn default() -> Self { let image_data = std::fs::read(TEMP_RESULT_PATH).expect("Failed to read image file");

        fs::remove_file(TEMP_RESULT_PATH).expect("File delete failed on TEMP_RESULT_PATH");
    
        Self {
            image: RetainedImage::from_image_bytes(TEMP_RESULT_PATH, &image_data).unwrap(),
        }
    }
    

    }

    impl eframe::App for ImagePreview { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { egui::CentralPanel::default().show(ctx, |ui| { self.image.show(ui); }); } }

    opened by plyght 1
Owner
Face
The Greatest Young Mind Of This Generation. Follow For More Family Friendly No Swearing Code :‎smile:
Face
A blazingly fast rust-based bionic reader for blazingly fast reading within a terminal console 🦀

This Rust-based CLI tool reads text and returns it back in bionic reading format for blazingly fast loading and even faster reading! Bionic reading is

Ismet Handzic 5 Aug 5, 2023
Save image from your clipboard 📋 as an image file directly from your command line! 🔥

Clpy ?? Save copied image from clipboard as an image file directly from your command line! Note It works only on windows as of now. I'll be adding sup

Piyush Suthar 13 Nov 28, 2022
Tight Model format is a lossy 3D model format focused on reducing file size as much as posible without decreasing visual quality of the viewed model or read speeds.

What is Tight Model Format The main goal of the tmf project is to provide a way to save 3D game assets compressed in such a way, that there are no not

null 59 Mar 6, 2023
A command-line tool aiming to upload the local image used in your markdown file to the GitHub repo and replace the local file path with the returned URL.

Pup A command line tool aiming to upload the local image used in your markdown file to the GitHub repo and replace the local file path with the return

SteveLau 11 Aug 17, 2022
SAORI for UKAGAKA. Convert a image file to resized png file.

Resized Png GitHub repository これは何? デスクトップマスコット、「伺か」で使用できるSAORIの一種です。 機能としては、指定した画像ファイルを拡大または縮小し、pngとして出力します。 「伺か」「SAORI」等の用語については詳しく説明いたしませんのでご了承下さい。

月波 清火 2 Jan 3, 2023
Single File Assets is a file storage format for images

SFA (Rust) Single File Assets is a file storage format for images. The packed images are not guaranteed to be of same format because the format while

null 1 Jan 23, 2022
Conference Monitoring Project based on Image Recognition that uses Rust Language and AWS Rekognition service to get the level of image similarity.

Conference Monitoring System based on Image Recognition in Rust This is a Conference Monitoring Project based on Image Recognition that uses Rust Lang

Pankaj Chaudhary 6 Dec 18, 2022
Given a set of kmers (fasta format) and a set of sequences (fasta format), this tool will extract the sequences containing the kmers.

Kmer2sequences Description Given a set of kmers (fasta / fastq [.gz] format) and a set of sequences (fasta / fastq [.gz] format), this tool will extra

Pierre Peterlongo 22 Sep 16, 2023
CLI application to run clang-format on a set of files specified using globs in a JSON configuration file.

run_clang_format CLI application for running clang-format for an existing .clang-format file on a set of files, specified using globs in a .json confi

martin 6 Dec 16, 2022
A low-level MVCC file format for storing blobs.

Sediment This repository isn't ready for public consumption. It just reached a stage where I wanted to start sharing ideas with others as well as usin

Khonsu Labs 24 Jan 8, 2023