I am trying to resize the images uploaded to my container in order to create thumbnails and various other versions of my images for my site.
The images I upload have to correct content-type "image/jpeg" but when I create a new version of them using the code below it turns out as "application/octet-stream".
What am I missing here?
using ImageResizer;
using ImageResizer.ExtensionMethods;
public static void Run(Stream myBlob, string blobname, string blobextension, Stream outputBlob, TraceWriter log)
{
log.Info($"C# Blob trigger function Processed blob\n Name:{blobname} \n Size: {myBlob.Length} Bytes");
var instructions = new Instructions
{
Width = 570,
Mode = FitMode.Crop,
Scale = ScaleMode.Both,
};
ImageBuilder.Current.Build(new ImageJob(myBlob, outputBlob, instructions));
}
Edit: The solution.
#r "Microsoft.WindowsAzure.Storage"
using ImageResizer;
using ImageResizer.ExtensionMethods;
using Microsoft.WindowsAzure.Storage.Blob;
public static void Run(Stream myBlob, string blobname, string blobextension, CloudBlockBlob outputBlob, TraceWriter log)
{
log.Info($"C# Blob trigger function Processed blob\n Name:{blobname} \n Size: {myBlob.Length} Bytes");
var instructions = new Instructions
{
Width = 570,
Mode = FitMode.Crop,
Scale = ScaleMode.Both
};
Stream stream = new MemoryStream();
ImageBuilder.Current.Build(new ImageJob(myBlob, stream, instructions));
stream.Seek(0, SeekOrigin.Begin);
outputBlob.Properties.ContentType = "image/jpeg";
outputBlob.UploadFromStream(stream);
}