# `Plushie.Command.Image`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/command/image.ex#L1)

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")

# `clear_images`

```elixir
@spec clear_images() :: Plushie.Command.t()
```

Clears all in-memory images.

# `create_image`

```elixir
@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).

# `create_image_rgba`

```elixir
@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).

# `delete_image`

```elixir
@spec delete_image(handle :: String.t()) :: Plushie.Command.t()
```

Deletes an in-memory image by handle name.

# `list_images`

```elixir
@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" => [...]}}`.

# `update_image`

```elixir
@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).

# `update_image_rgba`

```elixir
@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).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
