[][src]Crate favy

A simple solution for generating favicon schemes.

Overview

Favy is a library for encoding favicon schemes, based on ikon. It provides functionalities for quickly rasampling multiple pictures and cobining them into favicons.

Favicons are represented as maps between positive integers and images. An entry is a key-value pair contained in an favicon.

use favy::{resample, encode::{Encode, Save}, Image, Favicon, Size};
 
fn main() -> io::Result<()> {
    // Initialize the icon
    let mut icon = Favicon::new();
 
    // Add a single entry
    let image = Image::open("example.png")?;
    icon.add_entry(resample::linear, &image, Size(32))?;
 
    // Add multiple entries
    icon.add_entries(
        resample::linear,
        &image,
        vec![Size(64), Size(128), Size(256)]
    )?;
 
    // Save the icon to disk
    icon.save("~/favicon/")
}

Resampling

Raster graphics are scaled using resampling filters, which are represented by functions that take a source image and a size and return a re-scaled image.

This allows the users of this crate to provide their custom resampling filters. Common resampling filters are provided in the resample module.

Vector graphics are never resampled.

Re-exports

pub extern crate ikon;
pub use ikon::image;
pub use ikon::resvg;
pub use ikon::resvg::usvg;
pub use ikon::resvg::raqote;

Modules

resample

A collection of commonly used resampling filters.

Structs

Favicon

A comprehensive favicon encoder.

Size

A representation of the dimensions of a square picture. Note that Size(0) represents a 65536x65536 entry.

Enums

EncodingError

The error type for operations of the Encode trait.

Image

A uniun type for raster and vector graphics.

Traits

Encode

The Encode trait represents a generic icon encoder, providing basic inicialization methods as well as functionality for adding entries.

Save

The Save trait provides functionality for saving the contents of an Encode to the local file system.