Fixed Cover Gen on PDFs (#3028)
This commit is contained in:
parent
7997cd6329
commit
99c2dfb467
6 changed files with 760 additions and 11 deletions
|
@ -54,7 +54,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CsvHelper" Version="33.0.1" />
|
||||
<PackageReference Include="MailKit" Version="4.6.0" />
|
||||
<PackageReference Include="MailKit" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.6">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<PackageReference Include="Flurl" Version="3.0.7" />
|
||||
<PackageReference Include="Flurl.Http" Version="3.2.4" />
|
||||
<PackageReference Include="Hangfire" Version="1.8.14" />
|
||||
<PackageReference Include="Hangfire.InMemory" Version="0.10.0" />
|
||||
<PackageReference Include="Hangfire.InMemory" Version="0.10.3" />
|
||||
<PackageReference Include="Hangfire.MaximumConcurrentExecutions" Version="1.1.0" />
|
||||
<PackageReference Include="Hangfire.Storage.SQLite" Version="0.4.2" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.61" />
|
||||
|
@ -95,7 +95,7 @@
|
|||
<PackageReference Include="Serilog.Sinks.SignalR.Core" Version="0.1.2" />
|
||||
<PackageReference Include="SharpCompress" Version="0.37.2" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
|
||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.26.0.92422">
|
||||
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.28.0.94264">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -237,18 +237,40 @@ public class ImageService : IImageService
|
|||
using var sourceImage = Image.NewFromStream(stream);
|
||||
if (stream.CanSeek) stream.Position = 0;
|
||||
|
||||
var scalingSize = GetSizeForDimensions(sourceImage, targetWidth, targetHeight);
|
||||
var scalingCrop = GetCropForDimensions(sourceImage, targetWidth, targetHeight);
|
||||
|
||||
using var thumbnail = sourceImage.ThumbnailImage(targetWidth, targetHeight,
|
||||
size: GetSizeForDimensions(sourceImage, targetWidth, targetHeight),
|
||||
crop: GetCropForDimensions(sourceImage, targetWidth, targetHeight));
|
||||
size: scalingSize,
|
||||
crop: scalingCrop);
|
||||
|
||||
var filename = fileName + encodeFormat.GetExtension();
|
||||
_directoryService.ExistOrCreate(outputDirectory);
|
||||
|
||||
try
|
||||
{
|
||||
_directoryService.FileSystem.File.Delete(_directoryService.FileSystem.Path.Join(outputDirectory, filename));
|
||||
} catch (Exception) {/* Swallow exception */}
|
||||
thumbnail.WriteToFile(_directoryService.FileSystem.Path.Join(outputDirectory, filename));
|
||||
return filename;
|
||||
|
||||
try
|
||||
{
|
||||
thumbnail.WriteToFile(_directoryService.FileSystem.Path.Join(outputDirectory, filename));
|
||||
|
||||
return filename;
|
||||
}
|
||||
catch (VipsException)
|
||||
{
|
||||
// NetVips Issue: https://github.com/kleisauke/net-vips/issues/234
|
||||
// Saving pdf covers from a stream can fail, so revert to old code
|
||||
|
||||
if (stream.CanSeek) stream.Position = 0;
|
||||
using var thumbnail2 = Image.ThumbnailStream(stream, targetWidth, height: targetHeight,
|
||||
size: scalingSize,
|
||||
crop: scalingCrop);
|
||||
thumbnail2.WriteToFile(_directoryService.FileSystem.Path.Join(outputDirectory, filename));
|
||||
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
public string WriteCoverThumbnail(string sourceFile, string fileName, string outputDirectory, EncodeFormat encodeFormat, CoverImageSize size = CoverImageSize.Default)
|
||||
|
|
|
@ -235,7 +235,7 @@ public static class Parser
|
|||
// [SugoiSugoi]_NEEDLESS_Vol.2_-_Disk_The_Informant_5_[ENG].rar, Yuusha Ga Shinda! - Vol.tbd Chapter 27.001 V2 Infection ①.cbz,
|
||||
// Nagasarete Airantou - Vol. 30 Ch. 187.5 - Vol.30 Omake
|
||||
new Regex(
|
||||
@"^(?<Series>.+?)(\s*Chapter\s*\d+)?(\s|_|\-\s)+Vol(ume)?\.?(\d+|tbd|\s\d).+?",
|
||||
@"^(?<Series>.+?)(?:\s*|_|\-\s*)+(?:Ch(?:apter|\.|)\s*\d+(?:\.\d+)?(?:\s*|_|\-\s*)+)?Vol(?:ume|\.|)\s*(?:\d+|tbd)(?:\s|_|\-\s*).+",
|
||||
MatchOptions, RegexTimeout),
|
||||
// Ichiban_Ushiro_no_Daimaou_v04_ch34_[VISCANS].zip, VanDread-v01-c01.zip
|
||||
new Regex(
|
||||
|
@ -764,7 +764,10 @@ public static class Parser
|
|||
var group = matches
|
||||
.Select(match => match.Groups["Series"])
|
||||
.FirstOrDefault(group => group.Success && group != Match.Empty);
|
||||
if (group != null) return CleanTitle(group.Value);
|
||||
if (group != null)
|
||||
{
|
||||
return CleanTitle(group.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue