public override async Task <GetThumbnailResponse> GetThumbnail(GetThumbnailRequest request)
        {
            var response = new GetThumbnailResponse();

            try
            {
                var apiKeyServiceClientCredentials = new ApiKeyServiceClientCredentials(request.EndPointKey1);
                var delegatingHandlers             = new System.Net.Http.DelegatingHandler[] { };

                IComputerVisionClient computerVision = new ComputerVisionClient(
                    credentials: apiKeyServiceClientCredentials,
                    handlers: delegatingHandlers)
                {
                    Endpoint = request.EndPoint
                };

                response.Thumbnail = await computerVision.GenerateThumbnailInStreamAsync(
                    image : request.ImageStream,
                    width : request.ThumbnailSize.Width,
                    height : request.ThumbnailSize.Height,
                    smartCropping : request.ThumbnailSize.SmartCropping);

                response.Success = true;
            }
            catch (Exception e)
            {
                response.FailureInformation = e.Message;
            }

            return(response);
        }
예제 #2
0
        public override async Task <GetThumbnailResponse> GetThumbnail(GetThumbnailRequest request)
        {
            var cognitiveServicesRestHttpClient = new CognitiveServicesRestHttpClient();
            var restHttpResponse = await cognitiveServicesRestHttpClient.GetRestHttpStreamResponse(request);

            var servicesStreamResponseApi = new GetThumbnailResponse
            {
                Success             = restHttpResponse.Success,
                ImplementedInModule = restHttpResponse.ImplementedInModule,
                FailureInformation  = restHttpResponse.FailureInformation,
                Thumbnail           = restHttpResponse.RestResponse,
            };

            return(servicesStreamResponseApi);
        }