graphitepdf-image 0.4.0

Image primitives for GraphitePDF.
Documentation

Overview

graphitepdf-image provides typed image sources, decoded image assets, and async resolution helpers for raster and SVG image inputs.


Scope

graphitepdf-image contains:

  • ImageSource with data, local, remote, and data-URI variants
  • ImageFormat, RasterImage, SvgImage, and Image
  • ImageCache and ResolveImageOptions
  • async asset resolution helpers such as resolve_image() and resolve_image_with_options()

Installation

cargo add graphitepdf-image

API Summary

Category Items
Image sources ImageSource, DataImageSource, LocalImageSource, RemoteImageSource, DataUriImageSource
Source options RemoteMethod, RemoteCredentials, ResolveImageOptions
Decoded assets Image, RasterImage, SvgImage, ImageAsset
Runtime helpers ImageCache, resolve_image(), resolve_image_with_options()

Example

use graphitepdf_image::{
    DataImageSource, ImageFormat, ImageSource, LocalImageSource, RemoteImageSource,
};

fn main() {
    let inline: ImageSource = DataImageSource::new(vec![137, 80, 78, 71], ImageFormat::Png).into();
    let local: ImageSource = LocalImageSource::new("assets/logo.svg")
        .with_format(ImageFormat::Svg)
        .into();
    let remote: ImageSource = RemoteImageSource::new("https://example.com/logo.png").into();

    let _sources = [inline, local, remote];
}

Design Principles

  • keep image inputs typed and explicit
  • separate source descriptions from decoded assets
  • support caching and async loading without forcing rendering policy
  • make SVG images first-class alongside raster images

Role In GraphitePDF

This crate is a shared asset service for layout, render, document, and kit. It is where raw image inputs become reusable Image assets.


License

MIT