#image #border #frame #command-line-tool #graphics

bin+lib oliframe

Add a simple border to one or more images

5 releases

new 0.1.4 Apr 14, 2024
0.1.3 Apr 8, 2024
0.1.2 Feb 27, 2024
0.1.1 Jan 25, 2024
0.1.0 Jan 16, 2024

#1555 in Command line utilities

Download history 4/week @ 2024-01-12 5/week @ 2024-01-19 1/week @ 2024-01-26 13/week @ 2024-02-16 174/week @ 2024-02-23 56/week @ 2024-03-01 6/week @ 2024-03-08 1/week @ 2024-03-15 38/week @ 2024-03-29 142/week @ 2024-04-05

181 downloads per month

MIT license

25KB
407 lines

oliframe

oliframe crates.io docs.rs MIT license

oliframe is a simple command line tool to add borders to images. It can process a single image or multiple directories at a time.

Installation

For command-line usage

cargo install oliframe

For library usage

While the purpose of this project is to provide a command-line tool, the underlying library can be used in other projects.

cargo add oliframe

Command-Line Usage

Option Description
-f, --file <FILENAME> One or more input files
-d, --dir <DIR> Director(y/ies) to search for input files
-R, --recursive Recursively search for input files in the specified director(y/ies)
-x, --extension <FMT> File extension(s) of input files to accept (must be exact match, ie: "jpg" != "jpeg" != "JPG")
-o, --output <DEST> Output destination
-p, --prefix <PREFIX> Prefix to prepend to output files
-s, --suffix <SUFFIX> Suffix to append to output files
-C, --pct <%WIDTH> Border width in percent of average dimension, ie: (width + height) / 2.0. [default: 5]
-X, --px <PIXELS> Border with in pixels, default is 0 (disabled)
-c, --color <COLOR> Border color, any legal CSS color value [default: white]
-r, --radius <RADIUS> Border corner radius (in pixels; requires --px)
-v, --verbose Verbose output
-q, --quiet Quiet output -- suppresses all output except errors
--dry-run Dry run (don't actually create output files)
-y, --overwrite Overwrite existing files. Default is to ask for each image before overwriting if this flag is not specified
-h, --help Print help
-V, --version Print version
# Add a default white border to all images in the current directory
oliframe
# Add a 20% black border to a single image
oliframe -w 20 -c black image.jpg
# Add a 10% white border to all images in a directory
oliframe -w 10 -c white -d images
# Add a default border to all images in a directory and save them with a new suffix
oliframe -s _bordered -d images

Library Usage

The library only exposes one function, add_border, which expects an &image::DynamicImage as input and returns a new image::DynamicImage with the border applied. Loading and saving images is left to the user.

use oliframe::*;

fn main() {
    let img = image::open("image.jpg").unwrap();
    let bordered_img = add_border(&img, BorderWidth::Percent(5), "white", None);
    bordered_img.save("image_bordered.jpg").unwrap();
}

Roadmap / Future Functionality

  • Add option (-W, --watch) to watch for changes in a directory and automatically add borders to new images

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

AI-Assisted Development

This project has been developed with the assistance of AI-powered tools, including ChatGPT and GitHub Copilot. These tools have contributed to various aspects of the code, ranging from generating initial code snippets to offering suggestions for code optimization and bug fixes. While these tools have aided in the development process, the design and implementation of this project is the work of the author.

Dependencies

~19MB
~175K SLoC