9 releases

0.2.0 Sep 6, 2024
0.1.7 Aug 19, 2024
0.1.6 Jul 1, 2024
0.1.5 Apr 29, 2024
0.1.1 Jan 25, 2024

#132 in Command line utilities

Download history 142/week @ 2024-06-28 32/week @ 2024-07-05 26/week @ 2024-07-26 3/week @ 2024-08-02 134/week @ 2024-08-16 14/week @ 2024-08-23 138/week @ 2024-09-06 32/week @ 2024-09-13

187 downloads per month

MIT license

1.5MB
2K SLoC

oliframe

oliframe crates.io docs.rs codecov MIT license

Oliframe is a command-line tool written in Rust to add simple colored frames (borders) around images. It is designed to efficiently batch process images with a consistent border style. Flexible options allow for customization of the border width, color, and corner radius.

This project was inspired by the style of posts by @officialmumbo on Instagram, but is not endorsed by or affiliated with him.

Installation

$ cargo install oliframe

Usage

$ oliframe --help
Usage: oliframe [OPTIONS]

Options:
  -v, --verbose  Verbose output
  -q, --quiet    Quiet output -- suppresses everything except errors
  -h, --help     Print help
  -V, --version  Print version

Input Options:
  -i, --input <FILE_OR_DIR>  One or more input file_collector or directories, if not specified, the current directory is used
  -R, --recursive            Recursively search for input file_collector in the specified director(y/ies)
  -x, --extension <XTN>      File extensions(s) to accept (must be exact match, i.e.: "jpg" != "jpeg" != "JPG")

Output Options:
      --dry-run               Dry run (don't create output file_collector)
  -o, --output <FILE/FOLDER>  Output destination. If skipped, each output file will be saved in the same directory as the input file
  -f, --flatten               Flatten the output directory structure when processing multiple input file_collector
  -p, --prefix <PREFIX>       Prefix to prepend to output file_collector
  -s, --suffix <SUFFIX>       Suffix to append to output file_collector
  -y, --overwrite             Overwrite existing files.  Defaults to no

Framing Options:
      --ar <RATIO>           Fix the final aspect ratio of the output image. Specify the ratio as a fraction (e.g.: "16:9") or a decimal (e.g.: "1.777")
  -c, --color <COLOR>        Color of the border/background.  Specify any valid CSS color [default: white]
  -r, --radius <RADIUS>      Add rounded corners to the image.
  -m, --margins <SIZE(S)>    Relative margins around the image, as a percentage of (width + height) / 2. Specify one to four values, separated by commas, in CSS order
  -P, --position <POSITION>  Relative position of the input image within the output image. Horizontal values: "left", "center", "right" Vertical values: "top", "center", "bottom"

Examples

The default behavior is to add a white border that's 5% of the image size to all images in the current directory. Oliframe will not overwrite existing files by default, so you must use the -y flag to allow overwriting.

$ oliframe -y

Example 1


Rounded corners can be added by specifying a radius. Instead of editing in place, you can optionally specify an output directory with the -o flag.

$ oliframe --radius 20 -o framed_images

Example 2


More complex borders can be created by specifying the color, final aspect ratio, and position of the image within the frame.

$ oliframe --color darkslategray --ar 1:1 --position bottom-left -m 10,50,10,10

Example 3

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

~6–15MB
~183K SLoC