silvia-odwyer / photon

⚡ Rust/WebAssembly image processing library
https://silvia-odwyer.github.io/photon
Apache License 2.0
2.72k stars 154 forks source link

Speed issue with pure rust usage #144

Closed Avocadocs closed 2 years ago

Avocadocs commented 2 years ago

Hey, I created new rust projet with photon only and I compiled it. When I run my code it takes minutes to generate image, is this normal ?

extern crate photon_rs;
use photon_rs::native::{open_image, save_image};
use photon_rs::channels::invert;
use photon_rs::multiple::blend;
use photon_rs::Rgba::set_alpha;

fn main() {

    let mut albedo = open_image("GunGS_Albedo.tga.png").unwrap();
    let mut metallic = open_image("GunGS_Metallic.tga.png").unwrap();
    let mut ao = open_image("GunGS_AO.tga.png").unwrap();

    invert(&mut metallic);

    blend(&mut albedo, &metallic, "multiply");

    blend(&mut albedo, &ao, "multiply");

    save_image(albedo, "diffuse.png")
}

Thanks

silvia-odwyer commented 2 years ago

@Avocadocs Just wondering if you've added the --release flag to the build command?

When running the demo, be sure to add the --release flag like so:

cargo run --release

This will ensure the build is optimized and that the performance can be maximized. It may solve your issue perhaps?

Avocadocs commented 2 years ago

Yes it's working now, I was not using it. Sorry for that and thanks for your time :)

silvia-odwyer commented 2 years ago

@Avocadocs That's no problem at all, I'm glad it's working now! 🎉 Always happy to help, and if you have any other queries about using the library etc, don't hesitate to let me know! 😄