Google Cloud Vision v1 API - Class Image (3.6.0)

public sealed class Image : IMessage<Image>, IEquatable<Image>, IDeepCloneable<Image>, IBufferMessage, IMessage

Reference documentation and code samples for the Google Cloud Vision v1 API class Image.

Client image to perform Google Cloud Vision API tasks over.

Inheritance

object > Image

Namespace

Google.Cloud.Vision.V1

Assembly

Google.Cloud.Vision.V1.dll

Constructors

Image()

public Image()

Image(Image)

public Image(Image other)
Parameter
Name Description
other Image

Properties

Content

public ByteString Content { get; set; }

Image content, represented as a stream of bytes. Note: As with all bytes fields, protobuffers use a pure binary representation, whereas JSON representations use base64.

Currently, this field only works for BatchAnnotateImages requests. It does not work for AsyncBatchAnnotateImages requests.

Property Value
Type Description
ByteString

Source

public ImageSource Source { get; set; }

Google Cloud Storage image location, or publicly-accessible image URL. If both content and source are provided for an image, content takes precedence and is used to perform the image annotation request.

Property Value
Type Description
ImageSource

Methods

FetchFromUri(string, HttpClient)

public static Image FetchFromUri(string uri, HttpClient httpClient = null)

Constructs an Image by downloading data from the given URI.

Parameters
Name Description
uri string

The URI to fetch. Must not be null.

httpClient HttpClient

The HttpClient to use to fetch the image, or null to use a default client.

Returns
Type Description
Image

The newly created image.

Remarks

Unlike FromUri(string), this method downloads the image locally then uploads it to the Google Cloud Vision server.

FetchFromUri(Uri, HttpClient)

public static Image FetchFromUri(Uri uri, HttpClient httpClient = null)

Constructs an Image by downloading data from the given URI.

Parameters
Name Description
uri Uri

The URI to fetch. Must not be null.

httpClient HttpClient

The HttpClient to use to fetch the image, or null to use a default client.

Returns
Type Description
Image

The newly created image.

Remarks

Unlike FromUri(string), this method downloads the image locally then uploads it to the Google Cloud Vision server.

FetchFromUriAsync(string, HttpClient)

public static Task<Image> FetchFromUriAsync(string uri, HttpClient httpClient = null)

Asynchronously constructs an Image by downloading data from the given URI.

Parameters
Name Description
uri string

The URI to fetch. Must not be null.

httpClient HttpClient

The HttpClient to use to fetch the image, or null to use a default client.

Returns
Type Description
TaskImage

A task representing the asynchronous operation. The result will be the newly created image.

Remarks

Unlike FromUri(Uri), this method downloads the image locally then uploads it to the Google Cloud Vision server.

FetchFromUriAsync(Uri, HttpClient)

public static Task<Image> FetchFromUriAsync(Uri uri, HttpClient httpClient = null)

Asynchronously constructs an Image by downloading data from the given URI.

Parameters
Name Description
uri Uri

The URI to fetch. Must not be null.

httpClient HttpClient

The HttpClient to use to fetch the image, or null to use a default client.

Returns
Type Description
TaskImage

A task representing the asynchronous operation. The result will be the newly created image.

Remarks

Unlike FromUri(Uri), this method downloads the image locally then uploads it to the Google Cloud Vision server.

FromBytes(byte[])

public static Image FromBytes(byte[] bytes)

Constructs an Image from the given byte array.

Parameter
Name Description
bytes byte

The bytes representing the raw image data.

Returns
Type Description
Image

The newly created image.

Remarks

This method copies the data from the byte array; modifications to bytes after this method returns will not be reflected in the image.

FromBytes(byte[], int, int)

public static Image FromBytes(byte[] bytes, int offset, int count)

Constructs an Image from a section of the given byte array.

Parameters
Name Description
bytes byte

The bytes representing the raw image data.

offset int

The offset into the byte array of the start of the data to include in the image.

count int

The number of bytes to include in the image.

Returns
Type Description
Image

The newly created image.

Remarks

This method copies the data from the byte array; modifications to bytes after this method returns will not be reflected in the image.

FromFile(string)

public static Image FromFile(string path)

Constructs an Image by loading data from the given file path.

Parameter
Name Description
path string

The file path to load image data from. Must not be null.

Returns
Type Description
Image

The newly created image.

FromFileAsync(string)

public static Task<Image> FromFileAsync(string path)

Asynchronously constructs an Image by loading data from the given file path.

Parameter
Name Description
path string

The file path to load image data from. Must not be null.

Returns
Type Description
TaskImage

The newly created image.

FromStream(Stream)

public static Image FromStream(Stream stream)

Constructs an Image by loading data from the given stream.

Parameter
Name Description
stream Stream

The stream to load image data from. Must not be null.

Returns
Type Description
Image

The newly created image.

FromStreamAsync(Stream)

public static Task<Image> FromStreamAsync(Stream stream)

Asynchronously constructs an Image by loading data from the given stream.

Parameter
Name Description
stream Stream

The stream to load image data from. Must not be null.

Returns
Type Description
TaskImage

The newly created image.

FromUri(string)

public static Image FromUri(string uri)

Constructs an Image with a Source property referring to a URI, which may either be a Google Cloud Storage URI or a publicly accessible HTTP or HTTPS URI. The image is fetched from the URI by the Google Cloud Vision server.

Parameter
Name Description
uri string

The URI of the image, which may either be a Google Cloud Storage URI of the form gs://bucket-name/file-name or a publicly accessibly HTTP or HTTPS URI. Must not be null.

Returns
Type Description
Image

The newly created image.

FromUri(Uri)

public static Image FromUri(Uri uri)

Constructs an Image with a Source property referring to a URI, which may either be a Google Cloud Storage URI or a publicly accessible HTTP or HTTPS URI. The image is fetched from the URI by the Google Cloud Vision server.

Parameter
Name Description
uri Uri

The URI of the image, which may either be a Google Cloud Storage URI of the form gs://bucket-name/file-name or a publicly accessibly HTTP or HTTPS URI. Must not be null.

Returns
Type Description
Image

The newly created image.