Example #1
0
        /// <inheritdoc />
        public byte[] GetContent(Guid pictureId, int maxWidth = 0, int maxHeight = 0)
        {
            var isResizing = maxWidth != 0 && maxHeight != 0;

            var storageKey = isResizing ? $"{pictureId}-{maxWidth}-{maxHeight}" : pictureId.ToString();

            var data = this.storageProvider.Get(storageKey);

            if (data != null)
            {
                return(data);
            }

            if (!isResizing)
            {
                return(null);
            }

            var fullSizeData = this.storageProvider.Get(pictureId.ToString());

            if (fullSizeData == null)
            {
                return(null);
            }

            data = PictureProcessing.Resize(fullSizeData, maxWidth, maxHeight);

            this.storageProvider.Store(storageKey, data);

            return(data);
        }
Example #2
0
        public void Resize_Should_Resize()
        {
            // Arrange
            var file = Files.GetSimpleImage();

            // Act
            var resizedData = PictureProcessing.Resize(file, 10, 11);
            var picture     = new Picture();

            PictureInfo.CompleteInformations(picture, resizedData);

            // Assert
            Assert.Equal(10, picture.Width);
            Assert.Equal(11, picture.Height);
        }