private imageObject ( boolean $encode ) : array | ||
$encode | boolean | If set to true, image bytes will be base64-encoded |
return | array | [Image](https://cloud.google.com/vision/reference/rest/v1/images/annotate#image) |
private function imageObject($encode)
{
if ($this->type === self::TYPE_BYTES) {
$bytes = (string) $this->image;
return ['content' => $encode ? base64_encode($bytes) : $bytes];
}
if ($this->type === self::TYPE_STRING) {
$string = $this->image;
return ['content' => $encode ? base64_encode($string) : $string];
}
return ['source' => ['gcsImageUri' => $this->image]];
}