[−][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
Format | Supported? |
---|---|
PNG | All supported color types |
JPEG | Baseline and progressive |
GIF | Yes |
BMP | Yes |
ICO | Yes |
TIFF | Baseline(no fax support), LZW , PackBits |
WEBP | Lossy(Luma channel only) |
PNM | PBM , PGM , PPM , standard PAM |
SVG | Limited(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 |
Ico | A collection of entries stored in a single |
PngSequence | A collection of images stored in a single |
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 |