Class Image (2.3.0)

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

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
NameDescription
otherImage

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
TypeDescription
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
TypeDescription
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
NameDescription
uriString

The URI to fetch. Must not be null.

httpClientHttpClient

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

Returns
TypeDescription
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
NameDescription
uriUri

The URI to fetch. Must not be null.

httpClientHttpClient

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

Returns
TypeDescription
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
NameDescription
uriString

The URI to fetch. Must not be null.

httpClientHttpClient

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

Returns
TypeDescription
Task<Image>

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
NameDescription
uriUri

The URI to fetch. Must not be null.

httpClientHttpClient

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

Returns
TypeDescription
Task<Image>

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
NameDescription
bytesByte[]

The bytes representing the raw image data.

Returns
TypeDescription
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[], Int32, Int32)

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

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

Parameters
NameDescription
bytesByte[]

The bytes representing the raw image data.

offsetInt32

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

countInt32

The number of bytes to include in the image.

Returns
TypeDescription
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
NameDescription
pathString

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

Returns
TypeDescription
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
NameDescription
pathString

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

Returns
TypeDescription
Task<Image>

The newly created image.

FromStream(Stream)

public static Image FromStream(Stream stream)

Constructs an Image by loading data from the given stream.

Parameter
NameDescription
streamStream

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

Returns
TypeDescription
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
NameDescription
streamStream

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

Returns
TypeDescription
Task<Image>

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
NameDescription
uriString

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
TypeDescription
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
NameDescription
uriUri

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
TypeDescription
Image

The newly created image.