Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当存储在azure blob存储中时,如何获取图像尺寸?_C#_Azure_Azure Storage Blobs - Fatal编程技术网

C# 当存储在azure blob存储中时,如何获取图像尺寸?

C# 当存储在azure blob存储中时,如何获取图像尺寸?,c#,azure,azure-storage-blobs,C#,Azure,Azure Storage Blobs,我有一个blob中的图像,我想读取图像尺寸(宽度和高度) 这是我从blob读取的函数: private static CloudBlockBlob ReadBlockBlob(string input, IConfigurationRoot config) { CloudStorageAccount storageAccount = new CloudStorageAccount( new Microsoft.WindowsAzure.Stora

我有一个blob中的图像,我想读取图像尺寸(宽度和高度)

这是我从blob读取的函数:

 private static CloudBlockBlob ReadBlockBlob(string input, IConfigurationRoot config)
    {
        CloudStorageAccount storageAccount = new CloudStorageAccount(
            new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(config["storageAccountName"], config["storageKeyValue"]), true);
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
        CloudBlobContainer container = blobClient.GetContainerReference(config["blobContainer"]);
        return container.GetBlockBlobReference(input);
    }
我在CloudBlockContainer和CloudBlockBlob中都没有看到任何有用的元数据

知道如何从水滴中获取图像的尺寸吗


谢谢

您无法通过blob的属性和元数据直接获取Azure存储上存在的映像blob的维度。唯一的方法是下载图像块并通过方法
System.Drawing.image.FromFile
System.Drawing.image.FromStream
将其转换为
image.Width
image.Height


或者,在上载图像时,需要首先向blob添加元数据以存储图像维度。然后,您可以从blob元数据中获取图像的维度,而无需下载。我建议使用这种方法来避免下载那些大型图像。

我的意思是,在创建blob时,最好将这些信息保存为元数据。我不知道是否有一种方法可以获得信息,而不只是拉整个图像和使用GDI。