Skip to main content

Crate imgscale

Crate imgscale 

Source
Expand description

A library for generating various sizes of an image and the appropriate html tag

§Example

[dependencies]
imgscale = "0.1.0"
use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = imgscale::Config::new(
        imgscale::ExportFormat::Jpeg,
        vec![400, 800, 1200, 2400, 3600],
        PathBuf::from("dist/assets/"),
        Some(PathBuf::from("dist/")),
    );

    let generated_images =
        imgscale::scale_image_from_file("src/assets/some-image.jpeg", &config)?;

    let img_tag = imgscale::build_img_tag(&generated_images, None, Some("Just some image"))?;

    println!("{}", img_tag);
    Ok(())
}

Re-exports§

pub use config::CacheMode;
pub use config::Config;
pub use config::ExportFormat;
pub use error::Error;
pub use error::Result;
pub use image::scale_image;
pub use image::scale_image_from_file;
pub use model::GeneratedImage;
pub use web::build_img_tag;

Modules§

config
error
image
model
web