[][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

This example is not tested
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

This example is not tested
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::usvg;
pub use resvg::raqote;

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 representation of a source image.

Traits

Icon

A generic representation of an icon encoder.