Shell-based image operations: sixel rendering, ASCII conversion, and format conversion via external tools.
These functions wrap external CLI tools (img2sixel, img2txt,
ImageMagick's convert) through Arrea.Command.execute/2 for
consistent timeout handling and structured errors.
Available tools
| Tool | Purpose | Required for |
|---|---|---|
img2sixel | Render image as sixel | Sixel protocol |
img2txt | Convert image to ASCII art | ASCII fallback |
convert | Image format conversion | Non-PNG image loading |
Summary
Functions
Converts an image to PNG using ImageMagick's convert.
Converts an image to ASCII using img2txt.
Renders an image to sixel format using img2sixel.
Functions
@spec convert_to_png(String.t(), pos_integer(), pos_integer()) :: {:ok, String.t()} | {:error, String.t()} | :tool_not_found
Converts an image to PNG using ImageMagick's convert.
Resizes to fit within width x height. Returns {:ok, tmp_path}
on success, or {:error, reason}. The caller is responsible for
cleaning up the temp file.
Returns :tool_not_found if convert is not installed.
@spec image_to_ascii(String.t(), pos_integer()) :: {:ok, String.t()} | {:error, String.t()} | :tool_not_found
Converts an image to ASCII using img2txt.
Returns {:ok, output_string} on success, {:error, reason} on failure,
or :tool_not_found if img2txt is not installed.
@spec render_sixel(String.t(), pos_integer(), pos_integer()) :: {:ok, String.t()} | {:error, String.t()} | :tool_not_found
Renders an image to sixel format using img2sixel.
Returns {:ok, output_string} on success, {:error, reason} on failure,
or :tool_not_found if img2sixel is not installed.