Exemple #1
0
        private byte[] GenerateThumbnail(
            string originalPath,
            string ffmpegFolder,
            MediaClassification mediaClassification)
        {
            Log.Logger.Debug("Generating thumbnail");

            switch (mediaClassification)
            {
            case MediaClassification.Image:
                return(GraphicsUtils.CreateThumbnailOfImage(originalPath, MaxPixelDimension, ImageFormat.Jpeg));

            case MediaClassification.Video:
                var tempFile = GraphicsUtils.CreateThumbnailForVideo(
                    originalPath,
                    ffmpegFolder,
                    _optionsService.Options.EmbeddedThumbnails);

                if (string.IsNullOrEmpty(tempFile))
                {
                    return(null);
                }

                return(File.ReadAllBytes(tempFile));

            case MediaClassification.Audio:
                return(_standardAudioThumbnail.Value);

            case MediaClassification.Slideshow:
                return(GetSlideshowThumbnail(originalPath));

            default:
                return(null);
            }
        }
Exemple #2
0
        private byte[] GetSlideshowThumbnail(string originalPath)
        {
            var file = new SlideFile(originalPath);

            if (file.SlideCount == 0)
            {
                return(_standardUnknownThumbnail.Value);
            }

            var slide = file.GetSlide(0);

            return(GraphicsUtils.CreateThumbnailOfImage(slide.Image, MaxPixelDimension));
        }