コード例 #1
0
ファイル: ImageProcessor.cs プロジェクト: rosenbjerg/NxPlx
        private async Task <bool> ProcessPoster(IPosterImageOwner imageOwner)
        {
            if (string.IsNullOrEmpty(imageOwner.PosterPath) || !string.IsNullOrEmpty(imageOwner.PosterBlurHash))
            {
                return(false);
            }

            var tempFile   = _tempFileService.GetFilename("download", ".jpg");
            var downloaded = await _detailsApi.DownloadImage(342, imageOwner.PosterPath, tempFile);

            if (!downloaded)
            {
                return(false);
            }
            await _dispatcher.Dispatch(new SetImageCommand <IPosterImageOwner>(imageOwner, tempFile, $"{Guid.NewGuid()}.jpg"));

            return(true);
        }
コード例 #2
0
        private async Task <string> SaveTempImage(string imageExtension, Stream imageStream, CancellationToken cancellationToken)
        {
            var tempFile = _tempFileService.GetFilename("image_upload", imageExtension);

            await using var outputStream = File.OpenWrite(tempFile);
            await imageStream.CopyToAsync(outputStream, cancellationToken);

            return(tempFile);
        }
コード例 #3
0
        public async Task <string> Handle(CreateSnapshotCommand @event, CancellationToken cancellationToken = default)
        {
            var tempFile = _tempFileService.GetFilename("generated", ".png");
            var analysis = await FFProbe.AnalyseAsync(@event.InputVideoFilePath);

            await FFMpeg.SnapshotAsync(@event.InputVideoFilePath, tempFile, new Size(@event.Width, @event.Height), analysis !.Duration * @event.SeekPercentage);

            return(tempFile);
        }