打开c#后转动图像

时间:2015-11-03 15:44:25

标签: c# asp.net image azure image-uploading

我在上传肖像图片方面遇到了问题。

当我上传风景图片时,我没有任何问题。当我上传肖像图像时,它会将我的图像转换为90度......:s

我查看了图片的临时文件,这是面向肖像的...... 上传到Azure存储或在位图/图像对象中打开时,它会旋转90度。位图/图像还将高度值作为宽度值。

有人知道答案吗?我没有在stackoverflow上找到任何类似的线程:(

// Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }


        var provider = new MultipartFormDataStreamProvider(Path.GetTempPath());
            await Request.Content.ReadAsMultipartAsync(provider);

        var storageAccount = Storage();

        // Create the blob client and reference the container
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
        CloudBlobContainer container = blobClient.GetContainerReference("images");

        MultipartFileData photoToUpload = provider.FileData[0];
        var contentType = photoToUpload.Headers.ContentType.MediaType;
        var extention = photoToUpload.Headers.ContentDisposition.FileName.Replace("\"", "").Split('.')[1];
        string imageName = String.Format("horse-{0}.{1}",Guid.NewGuid().ToString(),extention);

        // Upload image to Blob Storage

        CloudBlockBlob blockBlob = container.GetBlockBlobReference(imageName);
        blockBlob.Properties.ContentType = "image/JPEG";

        await blockBlob.UploadFromFileAsync(provider.FileData[0].LocalFileName, FileMode.Open);

0 个答案:

没有答案