Things used in this project

Code

Code snippetC#
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;

public static void Run(Stream inputBlob, Stream thumbnailBlob, TraceWriter log)
{
    string SubscriptionKey = "CognitiveServiceKey";

    using (var httpClient = new HttpClient())
    {
        httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", SubscriptionKey);
        using (HttpContent content = new StreamContent(inputBlob))
        {
            content.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/octet-stream");
            var uri = "https://api.projectoxford.ai/vision/v1.0/generateThumbnail?width=300&height=300&smartCropping=true";
            var response = httpClient.PostAsync(uri, content).Result;
            var responseBytes = response.Content.ReadAsByteArrayAsync().Result;

            //write to output thumb
            thumbnailBlob.Write(responseBytes, 0, responseBytes.Length);
        }
    }
}

Credits

418553
Achindra Bhatnagar
18 projects • 83 followers
Windows Kernel Hacker, IoT Hobbyist, Enthusiast, Developer and Dreamer
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog