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.
Namespace
Google.Cloud.Vision.V1Assembly
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
|
Returns | |
---|---|
Type | Description |
Image | The newly created image. |
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
|
Returns | |
---|---|
Type | Description |
Image | The newly created image. |
Unlike FromUri(String), this method downloads the image locally then uploads it to the Google Cloud Vision server.
FetchFromUriAsync(String, HttpClient)
public static async 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
|
Returns | |
---|---|
Type | Description |
Task<Image> | A task representing the asynchronous operation. The result will be the newly created image. |
Unlike FromUri(Uri), this method downloads the image locally then uploads it to the Google Cloud Vision server.
FetchFromUriAsync(Uri, HttpClient)
public static async 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
|
Returns | |
---|---|
Type | Description |
Task<Image> | A task representing the asynchronous operation. The result will be the newly created image. |
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. |
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 | |
---|---|
Name | Description |
bytes | Byte[] The bytes representing the raw image data. |
offset | Int32 The offset into the byte array of the start of the data to include in the image. |
count | Int32 The number of bytes to include in the image. |
Returns | |
---|---|
Type | Description |
Image | The newly created image. |
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 |
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 | |
---|---|
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 async 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 |
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 | |
---|---|
Name | Description |
uri | String The URI of the image, which may either be a Google Cloud Storage URI of the form |
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 |
Returns | |
---|---|
Type | Description |
Image | The newly created image. |