Exemplo n.º 1
0
 public ResizeSettings(ImageSize imageSize) : this(imageSize.Size)
 {
 }
Exemplo n.º 2
-1
        private static async Task<string> ResizeImage(Stream streamInput, CloudBlockBlob blobOutput, ImageSize size)
        {
            streamInput.Position = 0;

            using (var memoryStream = new MemoryStream()) {
                // use a memory stream, since using the blob stream directly causes InvalidOperationException due to the way image resizer works
                var instructions = new Instructions(imageDimensionsTable[size]);
                var job = new ImageJob(streamInput, memoryStream, instructions, disposeSource: false, addFileExtension: false);

                // use the advanced version of resize so that we can get the content type
                var result = ImageBuilder.Current.Build(job);

                memoryStream.Position = 0;
                await blobOutput.UploadFromStreamAsync(memoryStream);

                var contentType = result.ResultMimeType;
                blobOutput.Properties.ContentType = contentType;
                blobOutput.SetProperties();

                return contentType;
            }
        }