Fix Image-Processing:

Format is not supported by Imagesharp, throwing exception causing Job to fail.
This commit is contained in:
2025-06-28 20:00:01 +02:00
parent 7e34b3b91e
commit 861cf7e166

View File

@ -134,20 +134,35 @@ public class DownloadSingleChapterJob : Job
{ {
if (!TrangaSettings.bwImages && TrangaSettings.compression == 100) if (!TrangaSettings.bwImages && TrangaSettings.compression == 100)
{ {
Log.Debug($"No processing requested for image"); Log.Debug("No processing requested for image");
return; return;
} }
Log.Debug($"Processing image: {imagePath}"); Log.Debug($"Processing image: {imagePath}");
using Image image = Image.Load(imagePath); try
File.Delete(imagePath);
if(TrangaSettings.bwImages)
image.Mutate(i => i.ApplyProcessor(new AdaptiveThresholdProcessor()));
image.SaveAsJpeg(imagePath, new JpegEncoder()
{ {
Quality = TrangaSettings.compression using Image image = Image.Load(imagePath);
}); if (TrangaSettings.bwImages)
image.Mutate(i => i.ApplyProcessor(new AdaptiveThresholdProcessor()));
File.Delete(imagePath);
image.SaveAsJpeg(imagePath, new JpegEncoder()
{
Quality = TrangaSettings.compression
});
}
catch (Exception e)
{
Log.Error(e);
if (e is UnknownImageFormatException or NotSupportedException)
{
//If the Image-Format is not processable by ImageSharp, we can't modify it.
Log.Debug($"Unable to process {imagePath}: Not supported image format");
}else if (e is InvalidImageContentException)
{
Log.Debug($"Unable to process {imagePath}: Invalid Content");
}
}
} }
private void CopyCoverFromCacheToDownloadLocation(Manga manga) private void CopyCoverFromCacheToDownloadLocation(Manga manga)