1

I'm having a problem with uploading portrait Images.

When I upload a landscape image, I have no problems. When I upload a portrait image, it turns my image with 90 degrees... :s

I checked the temp file of the image and this is portrait orientated... When uploaded to Azure Storage or openend in a bitmap/Image object, it's turned 90 degrees. The bitmap/image also gives the height value as the width value.

Does someone know the answer? I didn't find any similar thread on 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);
Tim Barrass
  • 4,813
  • 2
  • 29
  • 55
Officer Jonez
  • 253
  • 2
  • 8

0 Answers0