예제 #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);
            }
        }