WordPress\AiClient\Results\DTO

GenerativeAiResult::toImageFilepublicWP 0.1.0

Converts the first candidate to an image file.

Method of the class: GenerativeAiResult{}

No Hooks.

Returns

File. The image file.

Usage

$GenerativeAiResult = new GenerativeAiResult();
$GenerativeAiResult->toImageFile(): File;

Changelog

Since 0.1.0 Introduced.

GenerativeAiResult::toImageFile() code WP 7.0

public function toImageFile(): File
{
    $file = $this->toFile();
    if (!$file->isImage()) {
        throw new RuntimeException(sprintf('File is not an image. MIME type: %s', $file->getMimeType()));
    }
    return $file;
}