In-memory image commands: create, update, delete, list, and clear.
Images are referenced by handle name in widget source props:
image("my-img", source: %{handle: "avatar"}, ...)Example
# Create from encoded file bytes
data = File.read!("photo.png")
Command.create_image("avatar", data)
# Create from raw RGBA pixels
Command.create_image_rgba("gradient", 256, 1, rgba_pixels)
# Update existing encoded image
Command.update_image("avatar", new_data)
# Update existing raw image
Command.update_image_rgba("gradient", 256, 1, new_rgba_pixels)
# Clean up
Command.delete_image("avatar")
Summary
Functions
Clears all in-memory images.
Creates an in-memory image from encoded PNG/JPEG bytes.
Creates an in-memory image from raw RGBA pixel data.
Deletes an in-memory image by handle name.
Lists all in-memory image handles.
Updates an existing in-memory image with new encoded PNG/JPEG bytes.
Updates an existing in-memory image with new raw RGBA pixel data.
Functions
@spec clear_images() :: Plushie.Command.t()
Clears all in-memory images.
@spec create_image(handle :: String.t(), data :: binary()) :: Plushie.Command.t()
Creates an in-memory image from encoded PNG/JPEG bytes.
The raw binary is stored as-is in the command payload. The protocol layer handles format-specific encoding (native binary for msgpack, base64 for JSON).
@spec create_image_rgba( handle :: String.t(), width :: pos_integer(), height :: pos_integer(), pixels :: binary() ) :: Plushie.Command.t()
Creates an in-memory image from raw RGBA pixel data.
The raw binary is stored as-is in the command payload. The protocol layer handles format-specific encoding (native binary for msgpack, base64 for JSON).
@spec delete_image(handle :: String.t()) :: Plushie.Command.t()
Deletes an in-memory image by handle name.
@spec list_images(tag :: Plushie.Command.event_tag()) :: Plushie.Command.t()
Lists all in-memory image handles.
The result arrives in update/2 as
%SystemEvent{type: :image_list, tag: tag, value: %{"handles" => [...]}}.
@spec update_image(handle :: String.t(), data :: binary()) :: Plushie.Command.t()
Updates an existing in-memory image with new encoded PNG/JPEG bytes.
The raw binary is stored as-is in the command payload. The protocol layer handles format-specific encoding (native binary for msgpack, base64 for JSON).
@spec update_image_rgba( handle :: String.t(), width :: pos_integer(), height :: pos_integer(), pixels :: binary() ) :: Plushie.Command.t()
Updates an existing in-memory image with new raw RGBA pixel data.
The raw binary is stored as-is in the command payload. The protocol layer handles format-specific encoding (native binary for msgpack, base64 for JSON).