Пример #1
0
 public CognativeService(ImageEntity imageEntity, BlobManager blobManager, TableManager tableManager, string subscriptionKey)
 {
     _imageEntity    = imageEntity;
     BlobManager     = blobManager;
     TableManager    = tableManager;
     SubscriptionKey = subscriptionKey;
 }
Пример #2
0
        public async Task <ImageEntity> Resize(ImageSize imageSize)
        {
            // create the query string
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            var(width, height)           = imageDimensionsTable[imageSize];
            queryString["width"]         = $"{width}";
            queryString["height"]        = $"{height}";
            queryString["smartCropping"] = "true";

            // make the request and get the resposne content
            var responseContent = await MakeRequest(queryString);

            // take the stream and add it to blob
            var blobUrl = "";

            switch (imageSize)
            {
            case ImageSize.ExtraSmall:
                blobUrl = await BlobManager.AddExtraSmallImage(responseContent, _imageEntity.OriginalImageUrl);

                _imageEntity.ExtraSmallImageUrl = blobUrl;
                break;

            case ImageSize.Small:
                blobUrl = await BlobManager.AddSmallImage(responseContent, _imageEntity.OriginalImageUrl);

                _imageEntity.SmallImageUrl = blobUrl;
                break;

            case ImageSize.Medium:
                blobUrl = await BlobManager.AddMediumImage(responseContent, _imageEntity.OriginalImageUrl);

                _imageEntity.MediumImageUrl = blobUrl;
                break;

            default:
                break;
            }

            return(_imageEntity);
        }
Пример #3
0
 public ImageAnalyzer(ImageEntity imageEntity, BlobManager blobManager, TableManager tableManager, string subscriptionKey)
     : base(imageEntity, blobManager, tableManager, subscriptionKey)
 {
 }