< Summary

Information
Class: Anichron.Worker.Ingestion.Proxy.ThumbnailGenerator
Assembly: Anichron.Worker
File(s): /home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Proxy/ImageProxyGenerators.cs
Tag: 19_45211875487
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 48
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_FileName()100%11100%
get_ProxyType()100%11100%
get_Bound()100%11100%
GenerateAsync(...)100%11100%

File(s)

/home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Proxy/ImageProxyGenerators.cs

#LineLine coverage
 1using Anichron.Core.Domain;
 2using Anichron.Worker.Settings;
 3using Microsoft.Extensions.Options;
 4using SixLabors.ImageSharp;
 5using SixLabors.ImageSharp.PixelFormats;
 6
 7namespace Anichron.Worker.Ingestion.Proxy;
 8
 9internal interface IImageProxyGenerator
 10{
 11    string FileName { get; }
 12    ProxyType ProxyType { get; }
 13
 14    /// <summary>
 15    /// The most pixels this generator uses. It receives its own copy of the upright source, already shrunk
 16    /// to fit this bound, and may modify that copy freely.
 17    /// </summary>
 18    ProxyBound Bound { get; }
 19
 20    Task<byte[]> GenerateAsync(Image<Rgb24> image, CancellationToken ct);
 21}
 22
 6423internal sealed class ThumbnailGenerator(IImageProcessor imageProcessor, IOptions<WorkerSettings> options)
 24    : IImageProxyGenerator
 25{
 5426    public string FileName => "thumbnail.jpg";
 5427    public ProxyType ProxyType => ProxyType.Thumbnail;
 5428    public ProxyBound Bound => new(ProxyEdge.ShortEdge, options.Value.ThumbnailShortEdge);
 29    public Task<byte[]> GenerateAsync(Image<Rgb24> image, CancellationToken ct)
 5430        => imageProcessor.EncodeThumbnailAsync(image, ct);
 31}
 32
 33internal sealed class FullPreviewGenerator(IImageProcessor imageProcessor, IOptions<WorkerSettings> options)
 34    : IImageProxyGenerator
 35{
 36    public string FileName => "preview.jpg";
 37    public ProxyType ProxyType => ProxyType.FullPreview;
 38    public ProxyBound Bound => new(ProxyEdge.LongEdge, options.Value.PreviewLongEdge);
 39    public Task<byte[]> GenerateAsync(Image<Rgb24> image, CancellationToken ct)
 40        => imageProcessor.EncodeFullPreviewAsync(image, ct);
 41}
 42
 43internal sealed class BlurhashEncoder(IImageProcessor imageProcessor, IOptions<WorkerSettings> options)
 44{
 45    public ProxyBound Bound => new(ProxyEdge.LongEdge, options.Value.BlurhashSampleLongEdge);
 46    public Task<string> EncodeAsync(Image<Rgb24> image, CancellationToken ct)
 47        => imageProcessor.ComputeBlurhashAsync(image, ct);
 48}