[][src]Crate icon_baker

A simple solution for encoding common icon file formats, such as .ico and .icns. This crate is mostly a wrapper for other libraries, unifying existing APIs into a single, cohesive interface.

This crate serves as IconBaker CLI's internal library.

Overview

An icon stores a collection of small images of different sizes. Individial images within the icon are bound to a source image, which is rescaled to fit a particular size using a resampling filter.

Resampling filters are represented by functions that take a source image and a size and return a rescaled raw RGBA buffer. This allows the user of this crate to provide their custom resampling filter. Common resampling filters are provided by the resample module.

Examples

General Usage

use icon_baker::*;
  
fn main() -> icon_baker::Result<()> {
    let icon = Ico::new();
 
    match SourceImage::from_path("image.svg") {
        Some(img) => icon.add_entry(resample::linear, &img, 32),
        None      => Ok(())
    }
}

Writing to a File

use icon_baker::*;
use std::{io, fs::File};
  
fn main() -> io::Result<()> {
    let icon = PngSequence::new();
 
    /* Process the icon */
 
    let file = File::create("ou.icns")?;
    icon.write(file)
}

Supported Image Formats

FormatSupported?
PNGAll supported color types
JPEGBaseline and progressive
GIFYes
BMPYes
ICOYes
TIFFBaseline(no fax support), LZW, PackBits
WEBPLossy(Luma channel only)
PNM PBM, PGM, PPM, standard PAM
SVGLimited(flat filled shapes only)

Re-exports

pub extern crate nsvg;
pub use nsvg::image;

Modules

resample

A collection of commonly used resampling filters.

Structs

Icns

A collection of entries stored in a single .icns file.

Ico

A collection of entries stored in a single .ico file.

PngSequence

A collection of images stored in a single .tar file.

SvgImage

Enums

DynamicImage

A Dynamic Image

Error

The error type for operations of the Icon trait.

SourceImage

A representation of a source image.

Traits

GenericImage

A trait for manipulating images.

Icon

A generic representation of an icon encoder.

Type Definitions

Result
RgbaImage

Sendable Rgb + alpha channel image buffer

Size