image_outline 0.1.2

a barebones method for adding outline pixels to an image.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 44.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.89 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 7s Average build duration of successful builds.
  • all releases: 1m 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • BenjaminMassey/image_outline
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • BenjaminMassey

Maintenance crates-io api-docs dependency-status

image_outline

Copyright © 2025 Benjamin Massey (Version 0.1.2)

image_outline: a barebones method for adding outline pixels to an image.

Example Code

let original = image::ImageReader::open("input.png")
    .expect("Image file open failure.")
    .decode()
    .expect("Image file decode failure.");
let outlined = image_outline::outline_rgba8(
    &original.to_rgba8(),
    None,
    (0, 0, 0),
    1,
); // outline transparent background image with one "wide" black pixels
outlined.save("output.png").expect("Image save failure.");

Example Result

input

transforms into

output

Approach

This crate is described as a "barebones" method because it does nearly nothing to understand the actual structure of an image. Instead, it cycles through an image pixel-by-pixel and checks if said pixel is a "foreground" pixel. If so, it checks for surrounding "background" pixels (based on either transparency or given color), and replaces these background pixels with the given outline color.

This is intended for rather simple scenarios where the type of image data is rather well defined within a project. The project text-to-image in the examples folder was the original intention of this project, and thus demonstrates this the best. We can safely assume that the generated white-text image only contains joined white pixels and transparent pixels, as defined by how text-to-png functions (in consideration of our usage). More complex outlining scenarios will need more complex approaches.

License

This work is licensed under the "MIT License".