From 5fedc0fa244fb405702336b90661909f5808e94a Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Thu, 17 Feb 2022 23:09:12 +0100 Subject: [PATCH] save media thumbs as PNG --- zero.Core/Media/MediaCreator.cs | 7 ++----- zero.Core/Media/Models/MediaFocalPoint.cs | 2 ++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/zero.Core/Media/MediaCreator.cs b/zero.Core/Media/MediaCreator.cs index f6166214..a37f0703 100644 --- a/zero.Core/Media/MediaCreator.cs +++ b/zero.Core/Media/MediaCreator.cs @@ -74,14 +74,11 @@ public class MediaCreator : IMediaCreator imageFrame.Mutate(x => x.Resize(opts)); using MemoryStream stream = new(); - await imageFrame.SaveAsync(stream, new JpegEncoder() - { - Quality = 80 - }, cancellationToken); + await imageFrame.SaveAsync(stream, new PngEncoder(), cancellationToken); stream.Position = 0; - string thumbFilename = normalizedFilename.TrimEnd(extension) + "." + Safenames.File(key) + ".jpg"; + string thumbFilename = normalizedFilename.TrimEnd(extension) + "." + Safenames.File(key) + ".png"; string path = directory + '/' + thumbFilename; await FileSystem.CreateFile(path, stream, cancellationToken: cancellationToken); diff --git a/zero.Core/Media/Models/MediaFocalPoint.cs b/zero.Core/Media/Models/MediaFocalPoint.cs index 68645a29..6a89bc3b 100644 --- a/zero.Core/Media/Models/MediaFocalPoint.cs +++ b/zero.Core/Media/Models/MediaFocalPoint.cs @@ -8,4 +8,6 @@ public class MediaFocalPoint public decimal Left { get; set; } public decimal Top { get; set; } + + public bool NotDefault() => Left != 0.5m || Top != 0.5m; }