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 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 |
TaskImage | 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 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 |
TaskImage | 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[], 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. |
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 |
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. |