# `Kreuzberg.Image`
[🔗](https://github.com/kreuzberg-dev/kreuzberg/blob/main/lib/kreuzberg/image.ex#L1)

Structure representing an extracted image from a document.

Matches the Rust `ExtractedImage` struct.

## Fields

  * `:data` - Raw binary image data (PNG, JPEG, WebP, etc.)
  * `:format` - Image format string ("png", "jpeg", "webp", etc.)
  * `:image_index` - Zero-indexed position of image in the document/page
  * `:page_number` - Page number where image was found
  * `:width` - Image width in pixels
  * `:height` - Image height in pixels
  * `:colorspace` - Color space (e.g., "RGB", "CMYK", "Gray")
  * `:bits_per_component` - Bits per color component (e.g., 8, 16)
  * `:is_mask` - Whether this image is a mask image
  * `:description` - Optional description of the image
  * `:ocr_result` - Nested OCR extraction result map
  * `:bounding_box` - Bounding box coordinates if available

# `t`

```elixir
@type t() :: %Kreuzberg.Image{
  bits_per_component: non_neg_integer() | nil,
  bounding_box: map() | nil,
  colorspace: String.t() | nil,
  data: binary(),
  description: String.t() | nil,
  format: String.t(),
  height: non_neg_integer() | nil,
  image_index: non_neg_integer(),
  is_mask: boolean(),
  ocr_result: Kreuzberg.ExtractionResult.t() | nil,
  page_number: non_neg_integer() | nil,
  width: non_neg_integer() | nil
}
```

# `from_map`

```elixir
@spec from_map(map()) :: t()
```

Creates an Image struct from a map.

Handles `bytes::Bytes` serde serialization where binary data arrives
as a list of u8 integers, converting it to Elixir binary.

## Examples

    iex> Kreuzberg.Image.from_map(%{"format" => "png", "image_index" => 0, "width" => 800})
    %Kreuzberg.Image{format: "png", image_index: 0, width: 800}

# `has_data?`

```elixir
@spec has_data?(t()) :: boolean()
```

Returns whether the image has binary data.

# `new`

```elixir
@spec new(
  String.t(),
  keyword()
) :: t()
```

Creates a new Image struct.

## Parameters

  * `format` - The image format (e.g., "png", "jpeg")
  * `opts` - Optional keyword list of additional fields

# `to_map`

```elixir
@spec to_map(t()) :: map()
```

Converts an Image struct to a map.

---

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