Ootempl.ImageError exception (ootempl v0.3.0)
Raised when an image replacement operation fails.
This error indicates a problem with image file handling during template rendering. The error provides detailed context about which placeholder failed and why.
Common Reasons
:image_not_found_in_data- Placeholder exists in template but no image path provided in data:file_not_found- Image file doesn't exist at the provided path:file_not_readable- Image file exists but cannot be read (permission issue):unsupported_format- Image format is not supported (only PNG, JPEG, GIF supported):cannot_read_dimensions- Image file is corrupt or dimensions cannot be extracted
Examples
# Missing image path in data
iex> Ootempl.render("template.docx", %{}, "out.docx")
{:error, %Ootempl.ImageError{
message: "Image placeholder '{{image:logo}}' has no corresponding data key 'logo'",
placeholder_name: "logo",
image_path: nil,
reason: :image_not_found_in_data
}}
# Image file doesn't exist
iex> Ootempl.render("template.docx", %{"logo" => "/missing/logo.png"}, "out.docx")
{:error, %Ootempl.ImageError{
message: "Image file not found for placeholder 'logo': /missing/logo.png",
placeholder_name: "logo",
image_path: "/missing/logo.png",
reason: :file_not_found
}}
# Unsupported format
iex> Ootempl.render("template.docx", %{"logo" => "logo.bmp"}, "out.docx")
{:error, %Ootempl.ImageError{
message: "Unsupported image format for placeholder 'logo': logo.bmp (only PNG, JPEG, GIF supported)",
placeholder_name: "logo",
image_path: "logo.bmp",
reason: :unsupported_format
}}