Ragex.Image (Ragex v0.32.0)

View Source

Core image manipulation functions backed by the Image library (Vix/libvips).

Summary

Functions

Apply visual filters / enhancements.

Returns true when the optional :image dependency is compiled and loadable.

Generate a circular, squircle, or square avatar image.

Compare two images for visual diff/similarity.

Composite (overlay) an image on top of a base image.

Convert image format (e.g. PNG, JPEG, WebP, AVIF, TIFF, GIF).

Crop an image by bounding box or auto-trim.

Get detailed information and metadata for an image file.

Resize an image by scale factor, width/height dimensions, or crop focus.

Rotate or flip an image.

Functions

apply_filter(path, filter_name, opts \\ [])

@spec apply_filter(String.t(), atom() | String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Apply visual filters / enhancements.

available?()

@spec available?() :: boolean()

Returns true when the optional :image dependency is compiled and loadable.

:image is a native/NIF-backed dependency (Vix/libvips) that cannot be loaded from inside an escript archive, so callers embedding Ragex as a library should check this before relying on image-processing features.

avatar(path, output_path, opts \\ [])

@spec avatar(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}

Generate a circular, squircle, or square avatar image.

compare(image_a_path, image_b_path, opts \\ [])

@spec compare(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}

Compare two images for visual diff/similarity.

composite(base_path, overlay_path, output_path, opts \\ [])

@spec composite(String.t(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Composite (overlay) an image on top of a base image.

convert(path, output_path, opts \\ [])

@spec convert(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}

Convert image format (e.g. PNG, JPEG, WebP, AVIF, TIFF, GIF).

crop(path, opts)

@spec crop(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Crop an image by bounding box or auto-trim.

draw_text(path, output_path, text, opts \\ [])

@spec draw_text(String.t(), String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Render text onto an image.

info(path)

@spec info(String.t()) :: {:ok, map()} | {:error, term()}

Get detailed information and metadata for an image file.

resize(path, opts)

@spec resize(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Resize an image by scale factor, width/height dimensions, or crop focus.

rotate(path, opts)

@spec rotate(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Rotate or flip an image.