While I am linking my images, here is one when I use the code like this:
![Image]()
/// <summary>
/// Converts any image to png and uploads it to azure
/// </summary>
/// <param name="data">The byte array of the image</param>
/// <returns>The path to the azure blob</returns>
public async Task<string> ConvertImage(byte[] data, bool replaceBlack)
{
// Create our image
using (var image = new MagickImage())
{
image.Settings.BackgroundColor = MagickColors.Transparent;
// Read our image
image.Read(data);
// Create a new memory stream
using (var memoryStream = new MemoryStream())
{
// Set to a png
image.Format = MagickFormat.Png24;
image.Resize(600, 600);
// Write to our stream
image.Write(memoryStream);
// Reset the memory stream position
memoryStream.Position = 0;
// Create a new blob block to hold our image
var blockBlob = container.GetBlockBlobReference(Guid.NewGuid().ToString() + ".png");
// Upload to azure
await blockBlob.UploadFromStreamAsync(memoryStream);
// Return the blobs url
return blockBlob.StorageUri.PrimaryUri.ToString();
}
}
}
![Image](http://portalvhdswfr5fqfcn6r95.blob.core.windows.net/kudos-sports/f17b7a9b-fcc1-4713-8135-67cfe86f0336.png)