MCP PHP SDK

ImageContent extends Content

Base class for all content types in MCP.

Tags
author

Kyrian Obikwelu koshnawaza@gmail.com

Table of Contents

Properties

$data  : string
$mimeType  : string
$type  : string

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

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
self

fromFile()

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
throws
InvalidArgumentException

If the file doesn't exist

Return values
self

fromString()

public static fromString(string $data, string $mimeType) : self
Parameters
$data : string
$mimeType : string
Return values
self

jsonSerialize()

Convert the content to an array.

public jsonSerialize() : ImageContentData
Return values
ImageContentData

        
On this page

Search results