Fixed Cover Gen on PDFs (#3028)
This commit is contained in:
parent
7997cd6329
commit
99c2dfb467
6 changed files with 760 additions and 11 deletions
|
@ -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