[][src]Crate iconwriter

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.

IcoWriter serves as Iconiic's internal library.

Overview

An icon consists of a set of entries. An entry is simply an image that has a particular size. IcoWriter simply automates the process of re-scaling pictures and combining them into an icon.

Pictures 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.

Examples

General Usage

use iconwriter::{Ico, SourceImage, Icon};
use iconwriter::Error as IconError;
  
fn example() -> Result<(), IconError> {
    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 iconwriter::*;
use std::{io, fs::File};
  
fn example() -> io::Result<()> {
    let icon = PngSequence::new();
 
    /* Process the icon */
 
    let file = File::create("out.icns")?;
    icon.write(file)
}

Re-exports

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

Modules

resample

A collection of commonly used resampling filters.

Structs

Entry
Icns

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

Ico

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

NamedEntry
PngSequence

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

Enums

Error

The error type for operations of the Icon trait.

SourceImage

A unique type for raster and vector graphics.

Traits

Icon

A generic representation of an icon encoder.