Current section
Files
Jump to
Current section
Files
vidfomo_frame_geometry
README.md
README.md
# VidFomo Frame Geometry
Elixir helpers for planning video frame sizes and centered crops using integer
arithmetic. Given source and target dimensions, calculate a reduced aspect
ratio, fit size, or cover size and crop rectangle. This package only calculates
geometry: it does not read, edit, upload, or generate media, and it does not
call an API. [VidFomo](https://vidfomo.com/) is a browser-based AI video maker.
Installation and functionality have not yet been independently tested.
## Use
Once released, add this dependency to `mix.exs`:
```elixir
{:vidfomo_frame_geometry, "~> 0.1.0"}
```
Calculate a frame plan before passing the dimensions to a media processor:
```elixir
VidfomoFrameGeometry.aspect_ratio({1920, 1080})
# {16, 9}
VidfomoFrameGeometry.fit({1920, 1080}, {1080, 1080})
# {1080, 607}
VidfomoFrameGeometry.cover({1920, 1080}, {1080, 1080})
# %{resize: {1920, 1080}, crop: %{x: 420, y: 0, width: 1080, height: 1080}}
```
Input sizes must be pairs of positive integers. `fit/2` rounds down on the
unconstrained axis and clamps it to at least one pixel. `cover/2` rounds up and
returns crop coordinates relative to the resized frame. Both can enlarge the
source. Odd excess pixels fall on the right or bottom. These calculations do not
account for rotation metadata, non-square pixels, codec alignment requirements,
or any particular encoder's rounding and sampling behavior.
Requires Elixir 1.12 or later. No runtime dependencies. MIT license.