public function __construct($image, array $features, array $options = [])
{
$this->options = $options + ['imageContext' => [], 'maxResults' => []];
$this->features = $this->normalizeFeatures($features);
if ($image instanceof StorageObject) {
$identity = $image->identity();
$uri = sprintf('gs://%s/%s', $identity['bucket'], $identity['object']);
$this->type = self::TYPE_STORAGE;
$this->image = $uri;
} elseif (is_string($image)) {
$this->type = self::TYPE_STRING;
$this->image = $image;
} elseif (is_resource($image)) {
$this->type = self::TYPE_BYTES;
$this->image = Psr7\stream_for($image);
} else {
throw new InvalidArgumentException('Given image is not valid. ' . 'Image must be a string of bytes, a google storage object, or a resource.');
}
}