Function manganis::image

source ·
pub const fn image(path: &'static str) -> ImageAssetBuilder
Expand description

Create an image asset from the local path or url to the image

Note: This will do nothing outside of the mg! macro

You can collect images which will be automatically optimized with the image builder:

const _: &str = manganis::mg!(image("./rustacean-flat-gesture.png"));

Resize the image at compile time to make the assets file size smaller:

const _: &str = manganis::mg!(image("./rustacean-flat-gesture.png").size(52, 52));

Or convert the image at compile time to a web friendly format:

const _: &str = manganis::mg!(image("./rustacean-flat-gesture.png").format(ImageFormat::Avif).size(52, 52));

You can mark images as preloaded to make them load faster in your app

const _: &str = manganis::mg!(image("./rustacean-flat-gesture.png").preload());