mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 11:58:19 +02:00
Resize Covers on download
This commit is contained in:
@@ -4,6 +4,10 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using API.Workers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using SixLabors.ImageSharp.Processing.Processors.Transforms;
|
||||
using static System.IO.UnixFileMode;
|
||||
|
||||
namespace API.Schema.MangaContext;
|
||||
@@ -155,6 +159,18 @@ public class Manga : Identifiable
|
||||
return newJobs.ToArray();
|
||||
}
|
||||
|
||||
public async Task<(MemoryStream stream, FileInfo fileInfo)?> GetCoverImage(string cachePath, CancellationToken ct)
|
||||
{
|
||||
string fullPath = Path.Join(cachePath, CoverFileNameInCache);
|
||||
if (!File.Exists(fullPath))
|
||||
return null;
|
||||
|
||||
FileInfo fileInfo = new(fullPath);
|
||||
MemoryStream stream = new (await File.ReadAllBytesAsync(fullPath, ct));
|
||||
|
||||
return (stream, fileInfo);
|
||||
}
|
||||
|
||||
public override string ToString() => $"{base.ToString()} {Name}";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user