ImageContent extends Content
Base class for all content types in MCP.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Create a new ImageContent instance.
- fromArray() : self
- fromFile() : self
- Create a new ImageContent from a file path.
- fromString() : self
- jsonSerialize() : ImageContentData
- Convert the content to an array.
Properties
$data read-only
public
string
$data
$mimeType read-only
public
string
$mimeType
$type read-only
public
string
$type
Methods
__construct()
Create a new ImageContent instance.
public
__construct(string $data, string $mimeType) : mixed
Parameters
- $data : string
-
Base64-encoded image data
- $mimeType : string
-
The MIME type of the image
fromArray()
public
static fromArray(ImageContentData $data) : self
Parameters
- $data : ImageContentData
Return values
selffromFile()
Create a new ImageContent from a file path.
public
static fromFile(string $path[, string|null $mimeType = null ]) : self
Parameters
- $path : string
-
Path to the image file
- $mimeType : string|null = null
-
Optional MIME type override
Tags
Return values
selffromString()
public
static fromString(string $data, string $mimeType) : self
Parameters
- $data : string
- $mimeType : string
Return values
selfjsonSerialize()
Convert the content to an array.
public
jsonSerialize() : ImageContentData