Image is an image processing library for Elixir. It is based upon the fabulous vix library that provides a libvips wrapper for Elixir.
Image
is intended to provide well-documented, performant and reliable common image processing functions in an idiomatic Elixir functional style. It operates at a layer above the very comprehensive set of functions in Vix
and libvips
.
In a very simple image resizing benchmark, Image
is approximately 2 to 3 times faster than Mogrify
and uses about 5 times less memory.
Since Image
is based upon Vix
and libvips
it is performant, concurrent, pipelining and has a low memory footprint.
In this first release it focuses on resizing, cropping, masking, corner rounding, circular cropping, metadata extract, metadata minimisation. It also includes some simple functions to make it easy to resize and compress images for many well-known social media platforms at the correct size.
In the next two releases, Image
will:
- Provide streamed image processing. That will allow an image to be streamed from a file, or from S3 or from any Elixir stream or enumerable, process the image and then stream its output - including to chunked responses for HTTP applications.
- Provide bi-directional Integration with Nx that will efficiently share memory buffers and make it even simpler to involve image processing in ML applications.
Simple examples
Resize to fit
Image.resize(image, 200, crop: :none)Resize to fill
Image.resize(image, 200, crop: :attention)Crop image
Image.crop!(image, 550, 320, 200, 200)Rounded corners
image |> Image.resize!(200, crop: :attention) |> Image.rounded!()Avatar (circular mask, remove most metadata, crop to a subject of interest)
Image.avatar(image, 200)