public async Task ValidateCreatePageImagesAsync(long tenantId, long pageId, IBlobContent content)
        {
            // Get page details
            Page page = await _pageRepository.ReadPageAsync(tenantId, pageId);

            // Check that master page associated with page allows images
            MasterPage masterPage = await _masterPageRepository.ReadMasterPageAsync(tenantId, page.MasterPageId);

            if (!masterPage.HasImage)
            {
                throw new ValidationErrorException(new ValidationError(PagePropertyNames.ImageBlobId, PageResource.ImageNotAllowedMessage));
            }

            // Check that blob type is correct
            if (content.Type != ContentTypes.Gif && content.Type != ContentTypes.Jpeg && content.Type != ContentTypes.Png)
            {
                throw new ValidationErrorException(new ValidationError(PagePropertyNames.ImageBlobId, PageResource.ImageInvalidMessage));
            }

            // Check that supplied upload is an image
            ImageMetadata metadata = _imageAnalysisService.GetImageMetadata(content.Stream);

            if (metadata == null)
            {
                throw new ValidationErrorException(new ValidationError(PagePropertyNames.ImageBlobId, PageResource.ImageInvalidMessage));
            }

            // Check image dimension constraints (minimum width and height)
            if (metadata.Width < masterPage.ImageMinWidth.Value || metadata.Height < masterPage.ImageMinHeight.Value)
            {
                throw new ValidationErrorException(new ValidationError(PagePropertyNames.ImageBlobId, string.Format(PageResource.ImageDimensionsInvalidMessage, masterPage.ImageMinWidth.Value, masterPage.ImageMinHeight.Value)));
            }
        }
        private BlobImage GetBlobImage(IBlobContent content)
        {
            long          position = content.Stream.Position;
            ImageMetadata metadata = _imageAnalysisService.GetImageMetadata(content.Stream);

            content.Stream.Position = position;
            return(new BlobImage
            {
                BlobType = BlobType.Image,
                Height = metadata.Height,
                Width = metadata.Width
            });
        }