imageslapper 0.2.0

A tool for processing and manipulating images with parallelism and advanced rendering.
Documentation
use std::time::Instant;

use image::ImageReader;
use imageslapper::builders::ImageBuilder;

fn main() {
    let time = Instant::now();

    let jpeg_image = ImageReader::open("./examples/cat.jpg")
        .unwrap()
        .decode()
        .unwrap();

    // Load image directly from memory bytes
    let image = ImageBuilder::from_image(jpeg_image);

    let image_height = image.get_image().height();
    let image_width = image.get_image().width();

    // Double the width of the image to place two images side by side
    let mut blank_image = ImageBuilder::new(image_width * 2, image_height);

    // Get reference to the original image
    let image_ref = image.get_image();

    // Draw the image on the blank canvas twice side by side
    // Unchecked is unsafe but faster, use when you're sure the coordinates are valid
    unsafe {
        blank_image
            .insert_image_unchecked(&image_ref, 0, 0)
            .insert_image_unchecked(&image_ref, image_width, 0)
    };

    // Save the result
    blank_image.save_image("output.png");

    // log time it took
    println!("Time taken: {:?}", time.elapsed());
    println!("Image saved to output.png");
}