Skip to content

Commit c782be0

Browse files
committed
fix(Core): ensure OCR works with avif
1 parent d956557 commit c782be0

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

SnapX.Core/Job/TaskHelpers.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,17 @@ public static async Task<string> OCRImage(Image? image = null, string? filePath
778778
#endif
779779
var model = GetModelForLanguage(languageCode ?? "eng");
780780
using var ms = new MemoryStream();
781+
var configuration = new Configuration();
782+
configuration.ImageFormatsManager.AddImageFormat(AVIFFormat.Instance);
783+
configuration.ImageFormatsManager.SetDecoder(AVIFFormat.Instance, new AVIFDecoder());
784+
configuration.ImageFormatsManager.AddImageFormatDetector(new AVIFImageFormatDetector());
781785
try
782786
{
783787
if (filePath is not null && image is null)
784-
image = await Image.LoadAsync(filePath);
788+
image = await Image.LoadAsync(new DecoderOptions()
789+
{
790+
Configuration = configuration
791+
} , filePath);
785792
}
786793
catch (Exception ex)
787794
{

0 commit comments

Comments
 (0)