예제 #1
0
        public MediaResource MakeAvatarImage(
            string key,
            User createdByUser,
            DateTime createdOn,
            string originalFileName,
            ImageDimensions originalImageDimensions,
            string originalImageMimeType,
            List <ImageCreationTask> imageCreationTasks)
        {
            var mediaResource = new ImageMediaResource(Constants.MediaResourceTypes.Image, createdByUser, createdOn, key, null);

            _documentSession.Store(mediaResource);
            _documentSession.SaveChanges();

            mediaResource.Image.Original  = MakeOriginalImageFile(originalImageMimeType, MakeUri(mediaResource, "Original", originalImageMimeType), originalImageDimensions.Width, originalImageDimensions.Height, null, originalFileName, null);
            mediaResource.Image.Square50  = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Square50", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeSquare(100).Width, ImageDimensions.MakeSquare(100).Height, imageCreationTasks, "Square50", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Square100 = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Square100", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeSquare(200).Width, ImageDimensions.MakeSquare(200).Height, imageCreationTasks, "Square100", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Square200 = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Square200", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeSquare(400).Width, ImageDimensions.MakeSquare(400).Height, imageCreationTasks, "Square200", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);

            _documentSession.Store(mediaResource);
            _documentSession.SaveChanges();

            return(mediaResource);
        }
예제 #2
0
        public MediaResource MakeContributionExternalVideo(
            string key,
            User createdByUser,
            DateTime createdOn,
            string uri,
            string provider,
            object providerData,
            string videoId,
            ImageDimensions originalVideoDimensions,
            string originalThumbnailUri,
            ImageDimensions originalThumbnailDimensions,
            string originalThumbnailMimeType,
            Dictionary <string, string> metadata,
            List <ImageCreationTask> imageCreationTasks)
        {
            var mediaResource = new VideoMediaResource(Constants.MediaResourceTypes.Video, createdByUser, createdOn, key, metadata);

            _documentSession.Store(mediaResource);
            _documentSession.SaveChanges();

            var constrained240Dimensions = originalVideoDimensions.ResizeWithTargetDimensions(320, 240);
            var constrained480Dimensions = originalVideoDimensions.ResizeWithTargetDimensions(640, 480);
            var constrained600Dimensions = originalVideoDimensions.ResizeWithTargetDimensions(800, 600);
            var full640Dimensions        = originalVideoDimensions.ResizeWithTargetDimensions(640, 640);
            var full800Dimensions        = originalVideoDimensions.ResizeWithTargetDimensions(800, 800);
            var full1024Dimensions       = originalVideoDimensions.ResizeWithTargetDimensions(1024, 1024);

            mediaResource.Video.Original       = MakeOriginalVideoFile(provider, videoId, providerData, originalVideoDimensions.Width, originalVideoDimensions.Height, uri);
            mediaResource.Video.OriginalImage  = MakeOriginalImageFile(originalThumbnailMimeType, originalThumbnailUri, originalThumbnailDimensions.Width, originalThumbnailDimensions.Height, null, null, null);
            mediaResource.Video.Square50       = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Square50", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeSquare(100).Width, ImageDimensions.MakeSquare(100).Height, imageCreationTasks, "Square50", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Video.Square100      = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Square100", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeSquare(200).Width, ImageDimensions.MakeSquare(200).Height, imageCreationTasks, "Square100", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Video.Square200      = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Square200", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeSquare(400).Width, ImageDimensions.MakeSquare(400).Height, imageCreationTasks, "Square200", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Video.Constrained240 = MakeDerivedMediaResourceFile(uri, constrained240Dimensions.Width, constrained240Dimensions.Height, imageCreationTasks, "Constrained240", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Video.Constrained480 = MakeDerivedMediaResourceFile(uri, constrained480Dimensions.Width, constrained480Dimensions.Height, imageCreationTasks, "Constrained480", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Video.Constrained600 = MakeDerivedMediaResourceFile(uri, constrained600Dimensions.Width, constrained600Dimensions.Height, imageCreationTasks, "Constrained600", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Video.Full640        = MakeDerivedMediaResourceFile(uri, full640Dimensions.Width, full640Dimensions.Height, imageCreationTasks, "Full640", ImageResizeMode.Normal, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Video.Full800        = MakeDerivedMediaResourceFile(uri, full800Dimensions.Width, full800Dimensions.Height, imageCreationTasks, "Full800", ImageResizeMode.Normal, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Video.Full1024       = MakeDerivedMediaResourceFile(uri, full1024Dimensions.Width, full1024Dimensions.Height, imageCreationTasks, "Full1024", ImageResizeMode.Normal, Constants.ImageMimeTypes.Jpeg);

            _documentSession.Store(mediaResource);
            _documentSession.SaveChanges();

            return(mediaResource);
        }
예제 #3
0
        public MediaResource MakeContributionAudio(
            string key,
            User createdByUser,
            DateTime createdOn,
            string originalFileName,
            object id3Data,
            string standardMimeType,
            Dictionary <string, string> metadata)
        {
            var mediaResource = new AudioMediaResource(Constants.MediaResourceTypes.Audio, createdByUser, createdOn, key, metadata);

            _documentSession.Store(mediaResource);
            _documentSession.SaveChanges();

            var avatarUri    = @"/img/audio-avatar.png";
            var audioFileUri = _mediaFilePathFactory.MakeRelativeMediaFileUri(mediaResource.Id, "Original", MediaTypeUtility.GetStandardExtensionForMimeType(standardMimeType));

            mediaResource.Audio.Original       = MakeOriginalAudioFile(standardMimeType);
            mediaResource.Audio.Square50       = MakeDerivedMediaResourceFile(avatarUri, ImageDimensions.MakeSquare(100).Width, ImageDimensions.MakeSquare(100).Height);
            mediaResource.Audio.Square100      = MakeDerivedMediaResourceFile(avatarUri, ImageDimensions.MakeSquare(200).Width, ImageDimensions.MakeSquare(200).Height);
            mediaResource.Audio.Square200      = MakeDerivedMediaResourceFile(avatarUri, ImageDimensions.MakeSquare(400).Width, ImageDimensions.MakeSquare(400).Height);
            mediaResource.Audio.Constrained240 = MakeDerivedMediaResourceFile(audioFileUri, 100, 100);
            mediaResource.Audio.Constrained480 = MakeDerivedMediaResourceFile(audioFileUri, 200, 200);
            mediaResource.Audio.Constrained600 = MakeDerivedMediaResourceFile(audioFileUri, 400, 400);
            mediaResource.Audio.Full640        = MakeDerivedMediaResourceFile(audioFileUri, 640, 480);
            mediaResource.Audio.Full800        = MakeDerivedMediaResourceFile(audioFileUri, 800, 600);
            mediaResource.Audio.Full1024       = MakeDerivedMediaResourceFile(audioFileUri, 1024, 768);

            return(mediaResource);
        }
예제 #4
0
        public MediaResource MakeContributionImage(
            string key,
            User createdByUser,
            DateTime createdOn,
            string originalFileName,
            ImageDimensions originalImageDimensions,
            long originalSize,
            IDictionary <string, object> originalExifData,
            string originalImageMimeType,
            Dictionary <string, string> metadata,
            List <ImageCreationTask> imageCreationTasks)
        {
            var mediaResource = new ImageMediaResource(Constants.MediaResourceTypes.Image, createdByUser, createdOn, key, metadata);

            _documentSession.Store(mediaResource);
            _documentSession.SaveChanges();

            mediaResource.Image.Original       = MakeOriginalImageFile(originalImageMimeType, MakeUri(mediaResource, "Original", originalImageMimeType), originalImageDimensions.Width, originalImageDimensions.Height, originalExifData, originalFileName, originalSize);
            mediaResource.Image.Square50       = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Square50", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeSquare(100).Width, ImageDimensions.MakeSquare(100).Height, imageCreationTasks, "Square50", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Square100      = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Square100", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeSquare(200).Width, ImageDimensions.MakeSquare(200).Height, imageCreationTasks, "Square100", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Square200      = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Square200", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeSquare(400).Width, ImageDimensions.MakeSquare(400).Height, imageCreationTasks, "Square200", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Constrained240 = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Constrained240", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeRectangle(320, 240).Width, ImageDimensions.MakeRectangle(320, 240).Height, imageCreationTasks, "Constrained240", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Constrained480 = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Constrained480", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeRectangle(640, 480).Width, ImageDimensions.MakeRectangle(640, 480).Height, imageCreationTasks, "Constrained480", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Constrained600 = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Constrained600", Constants.ImageMimeTypes.Jpeg), ImageDimensions.MakeRectangle(800, 600).Width, ImageDimensions.MakeRectangle(800, 600).Height, imageCreationTasks, "Constrained600", ImageResizeMode.Crop, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Full640        = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Full640", Constants.ImageMimeTypes.Jpeg), originalImageDimensions.ResizeWithTargetDimensions(640, 640).Width, originalImageDimensions.ResizeWithTargetDimensions(640, 640).Height, imageCreationTasks, "Full640", ImageResizeMode.Normal, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Full800        = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Full800", Constants.ImageMimeTypes.Jpeg), originalImageDimensions.ResizeWithTargetDimensions(800, 800).Width, originalImageDimensions.ResizeWithTargetDimensions(800, 800).Height, imageCreationTasks, "Full800", ImageResizeMode.Normal, Constants.ImageMimeTypes.Jpeg);
            mediaResource.Image.Full1024       = MakeDerivedMediaResourceFile(MakeUri(mediaResource, "Full1024", Constants.ImageMimeTypes.Jpeg), originalImageDimensions.ResizeWithTargetDimensions(1024, 1024).Width, originalImageDimensions.ResizeWithTargetDimensions(1024, 1024).Height, imageCreationTasks, "Full1024", ImageResizeMode.Normal, Constants.ImageMimeTypes.Jpeg);

            _documentSession.Store(mediaResource);
            _documentSession.SaveChanges();

            return(mediaResource);
        }