Example #1
0
        public async Task Run([QueueTrigger(Constants.SquareImageQueue)] string imageName, ILogger log)
        {
            log.LogInformation($"C# Queue trigger function processed: {imageName}");

            var blobStream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, imageName);

            log.LogInformation($"BlobService has connectionString");
            var squareImageStream = ImageService.Square(blobStream);

            await BlobStorageService.UploadStreamToBlob(Constants.SquareImageContainer, imageName, squareImageStream);

            log.LogInformation($"Finished processing");
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            var blobName = req.Query["blobName"];

            var stream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, blobName);

            var mirror = ImageService.FlipHorizontal(stream);

            await BlobStorageService.UploadStreamToBlob(Constants.MirrorImageContainer, blobName, mirror);

            return(new OkResult());
        }
        public async Task <string> Run([QueueTrigger(Constants.GreyImageQueue)] string imageName,
                                       ILogger log)
        {
            log.LogInformation($"C# Queue trigger function processed: {imageName}");

            var blobStream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, imageName);

            log.LogInformation($"BlobService has connectionString");
            var greyStream = ImageService.GreyScale(blobStream);

            greyStream.Position = 0;

            await BlobStorageService.UploadStreamToBlob(Constants.GreyImageContainer, imageName, greyStream);

            log.LogInformation($"Finished processing");
            return(imageName);
        }
Example #4
0
        public async Task Run([TimerTrigger("0 */2 * * * *")] TimerInfo myTimer, ILogger log)
        {
            var blobNames = await BlobStorageService.GetFileNamesInContainer(Constants.ImageContainer);

            foreach (var blobName in blobNames)
            {
                log.LogDebug($"Processing blob {blobName}");
                var blobStream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, blobName);

                var rotateRight = ImageService.RotateClockwise(blobStream);
                await BlobStorageService.UploadStreamToBlob(Constants.ClockwiseImageContainer, blobName, rotateRight);

                blobStream.Position = 0;
                var rotateLeft = ImageService.RotateAntiClockwise(blobStream);
                await BlobStorageService.UploadStreamToBlob(Constants.AntiClockwiseImageContainer, blobName, rotateLeft);

                log.LogDebug($"Done processing blob {blobName}");
            }
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            var    blobName = req.Query["blobName"];
            var    func     = req.Query["func"];
            Stream imageStream;
            Stream changedImageStream;

            if (func.Count != 0)
            {
                switch (func[0])
                {
                case "mirror":
                    imageStream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, blobName);

                    changedImageStream = ImageService.FlipHorizontal(imageStream);
                    await BlobStorageService.UploadStreamToBlob(Constants.MirrorImageContainer, blobName, changedImageStream);

                    break;

                case "flip":
                    imageStream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, blobName);

                    changedImageStream = ImageService.FlipVertical(imageStream);
                    await BlobStorageService.UploadStreamToBlob(Constants.FlippedImageContainer, blobName, changedImageStream);

                    break;

                case "rotate":
                    imageStream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, blobName);

                    changedImageStream = ImageService.RotateClockwise(imageStream);
                    await BlobStorageService.UploadStreamToBlob(Constants.ClockwiseImageContainer, blobName, changedImageStream);

                    break;

                case "antirotate":
                    imageStream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, blobName);

                    changedImageStream = ImageService.RotateClockwise(imageStream);
                    await BlobStorageService.UploadStreamToBlob(Constants.AntiClockwiseImageContainer, blobName, changedImageStream);

                    break;

                case "greyscale":
                    imageStream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, blobName);

                    changedImageStream = ImageService.GreyScale(imageStream);
                    await BlobStorageService.UploadStreamToBlob(Constants.GreyImageContainer, blobName, changedImageStream);

                    break;
                }
            }
            else
            {
                imageStream = await BlobStorageService.GetBlobAsStream(Constants.ImageContainer, blobName);

                changedImageStream = ImageService.FlipHorizontal(imageStream);

                await BlobStorageService.UploadStreamToBlob(Constants.MirrorImageContainer, blobName, changedImageStream);
            }
            return(new OkResult());
        }