Current section

Files

Jump to
rbt_weave lib weave image.ex
Raw

lib/weave/image.ex

defmodule Weave.Image do
@moduledoc """
Thumbnail processing powered by Rust.
Downloads images, resizes to 256x256 WebP thumbnails, and computes
deterministic storage keys based on source URL SHA-256.
"""
@doc """
Computes the thumbnail storage key from a source URL.
Returns `"thumbnails/{sha256_hex[0..32]}.webp"`.
## Examples
iex> Weave.Image.thumbnail_key("https://example.com/photo.jpg")
"thumbnails/" <> _rest = Weave.Image.thumbnail_key("https://example.com/photo.jpg")
"""
defdelegate thumbnail_key(source_url), to: Weave.Native
@doc """
Downloads an image, resizes to 256x256 WebP, and computes the storage key.
Returns `{:ok, {key, webp_bytes}}` or `{:error, reason}`.
"""
defdelegate process_thumbnail(url), to: Weave.Native
end