Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Merge main into feature/ocr
cre8ive-marketing9993b9a34836
diff --cc README.mdindex 6a390ba6,d22ff3eb..4ad3a991--- a/README.md+++ b/README.md@@@ -169,9 -215,7 +215,7 @@@ It connects to the internet only- to ask GitHub (`api.github.com`) whether a newer release exists, shortly after start and then every few hours.Turn this off in Settings → About ("Check for updates automatically").- - to download the conversion engines you choose to install, from the official locations pinned in- [`engines.json`](src/Filee.Engines/Infrastructure/engines.json), and the text recognition (OCR) languages a preset- uses, pinned in [`ocr-languages.json`](src/Filee.Engines/Infrastructure/ocr-languages.json).-- to download the conversion engines you choose to install, from the official locations pinned in [`engines.json`](src/Filee.Engines/Infrastructure/engines.json).++- to download the conversion engines you choose to install, from the official locations pinned in [`engines.json`](src/Filee.Engines/Infrastructure/engines.json), and the text recognition (OCR) languages a preset uses, pinned in [`ocr-languages.json`](src/Filee.Engines/Infrastructure/ocr-languages.json).- when you click a link, which opens your web browser.## Sponsordiff --cc src/Filee.Core/Settings/AppSettings.csindex c9856e03,3eed0429..0e732dd0--- a/src/Filee.Core/Settings/AppSettings.cs+++ b/src/Filee.Core/Settings/AppSettings.cs@@@ -112,7 -112,7 +112,7 @@@ public sealed class DonutSettingpublic sealed class AppSettings{/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>-- public const int CurrentSchemaVersion = 39;++ public const int CurrentSchemaVersion = 40;public int SchemaVersion { get; set; } = CurrentSchemaVersion;diff --cc src/Filee.Core/Settings/UserDataStore.csindex 1bdfae95,6b8aa4d8..048dc125--- a/src/Filee.Core/Settings/UserDataStore.cs+++ b/src/Filee.Core/Settings/UserDataStore.cs@@@ -794,13 -794,9 +794,16 @@@ internal static class SettingsMigration// v38: Tajima embroidery designs (.dst) learn the vector donut; custom claims stay put.if (from < 38)changed |= LearnExtensions(profiles, out _, ["dst"]);- // v39: "Searchable PDF" (text recognition), after "Compress PDF" as in a new library, on no donut.- if (from < 39 && !presets.Any(p => p.Id == "searchable-pdf"))+ // v39: PowerShell scripts (.ps1) learn the text donut; custom claims stay put.+ if (from < 39)+ changed |= LearnExtensions(profiles, out _, ["ps1"]);++ // v40: "Searchable PDF" (text recognition), after "Compress PDF" as in a new library, on no donut.++ if (from < 40 && !presets.Any(p => p.Id == "searchable-pdf"))+ {+ var at = presets.FindIndex(p => p.Id == "compress-pdf");+ presets.Insert(at < 0 ? presets.Count : at + 1, BuiltInData.OcrPresets().Single());+ changed = true;+ }return changed;}diff --cc tests/Filee.Core.Tests/OcrRouteTests.csindex cb8023e9,00000000..e321eee8mode 100644,000000..100644--- a/tests/Filee.Core.Tests/OcrRouteTests.cs+++ b/tests/Filee.Core.Tests/OcrRouteTests.cs@@@ -1,116 -1,0 +1,116 @@@+// "Recognize text" (issue #288): Tesseract's OCR edges start a route only when the preset asks for them, and the+// route goes on from the searchable PDF.++using Filee.Core.Conversion;+using Filee.Core.Presets;+using Filee.Core.Settings;++namespace Filee.Core.Tests;++public class OcrRouteTests+{+ private static readonly ConversionEdge[] OcrEdges =+ [new("png", "pdf", Ocr: true), new("jpg", "pdf", Ocr: true), new("pdf", "pdf", Ocr: true)];++ private static string Steps(Route? route) => string.Join(", ", route!.Steps.Select(s => $"{s.Converter.Id}:{s.From}→{s.To}"));++ private static RoutePlanner Planner() => new([+ new FakeConverter("tesseract", OcrEdges),+ new FakeConverter("magick", new ConversionEdge("heic", "png"), new ConversionEdge("png", "pdf"), new ConversionEdge("jpg", "pdf")),+ new FakeConverter("docx", new ConversionEdge("pdf", "docx")),+ new FakeConverter("text", new ConversionEdge("pdf", "txt")),+ ]);++ [Fact]+ public void Ocr_edges_are_never_part_of_an_ordinary_route()+ {+ var planner = Planner();++ Assert.Equal("magick:png→pdf", Steps(planner.Plan("png", "pdf")));+ Assert.Null(planner.Plan("pdf", "pdf")); // no ordinary PDF → PDF edge here+ }++ [Fact]+ public void Asking_for_ocr_starts_with_tesseract_and_goes_on_from_its_pdf()+ {+ var planner = Planner();++ Assert.Equal("tesseract:jpg→pdf", Steps(planner.Plan("jpg", "pdf", ocr: true)));+ Assert.Equal("tesseract:pdf→pdf, docx:pdf→docx", Steps(planner.Plan("pdf", "docx", ocr: true)));+ Assert.Equal("tesseract:png→pdf, text:pdf→txt", Steps(planner.Plan("png", "txt", ocr: true)));+ // A picture Tesseract can't open becomes a PNG first.+ Assert.Equal("magick:heic→png, tesseract:png→pdf, docx:pdf→docx", Steps(planner.Plan("heic", "docx", ocr: true)));+ }++ [Fact]+ public void Without_tesseract_there_is_no_ocr_route()+ {+ var planner = new RoutePlanner([new FakeConverter("magick", new ConversionEdge("png", "pdf"))]);++ Assert.Null(planner.Plan("png", "pdf", ocr: true));+ Assert.False(planner.CanConvert("png", "pdf", ocr: true));+ }++ [Fact]+ public void Text_is_recognized_in_pdfs_and_pictures_for_document_targets()+ {+ var preset = new Preset { TargetFormat = "docx", Pdf = { Ocr = true } };++ Assert.True(preset.RecognizesTextOf("pdf"));+ Assert.True(preset.RecognizesTextOf("jpg"));+ Assert.False(preset.RecognizesTextOf("docx")); // already text+ Assert.False(new Preset { TargetFormat = "png", Pdf = { Ocr = true } }.RecognizesTextOf("pdf"));+ Assert.False(new Preset { TargetFormat = "docx" }.RecognizesTextOf("pdf"));+ }++ [Fact]+ public async Task A_job_with_ocr_runs_tesseract_before_the_document_writer()+ {+ using var dir = new TempDir();+ var scan = dir.File("scan.jpg");+ var tesseract = new FakeRecorder("tesseract", OcrEdges);+ var writer = new FakeRecorder("docx", new ConversionEdge("pdf", "docx"));+ var magick = new FakeRecorder("magick", new ConversionEdge("jpg", "pdf"));+ await using var queue = new JobQueue(new ConverterCatalog([tesseract, writer, magick]));++ var job = new ConversionJob([scan], new Preset { TargetFormat = "docx", Pdf = { Ocr = true } }, "Test");+ await queue.RunAsync(job);++ Assert.Equal(JobState.Completed, job.State);+ Assert.Equal([("jpg", "pdf", false)], tesseract.Steps);+ Assert.Equal([("pdf", "docx", false)], writer.Steps);+ Assert.Empty(magick.Steps);+ }++ [Fact]+ public async Task Pdfs_merged_into_one_are_recognized_first()+ {+ using var dir = new TempDir();+ var a = dir.File("a.pdf");+ var b = dir.File("b.jpg");+ var tesseract = new FakeRecorder("tesseract", OcrEdges);+ var merger = new FakeMerger();+ await using var queue = new JobQueue(new ConverterCatalog([tesseract]), merger);++ var job = new ConversionJob([a, b], new Preset { TargetFormat = "pdf", Pdf = { Ocr = true, MergeIntoSingle = true } }, "Test");+ await queue.RunAsync(job);++ Assert.Equal(JobState.Completed, job.State);+ Assert.Equal([("jpg", "pdf", false), ("pdf", "pdf", false)], tesseract.Steps.OrderBy(s => s.From));+ }++ [Fact]- public void A_version_38_library_gets_searchable_pdf_after_compress_pdf()++ public void A_version_39_library_gets_searchable_pdf_after_compress_pdf()+ {+ var presets = BuiltInData.CreatePresets();+ presets.RemoveAll(p => p.Id == "searchable-pdf");+ var profiles = BuiltInData.CreateProfiles();+- Assert.True(SettingsMigrations.ApplyToLibrary(38, presets, profiles));++ Assert.True(SettingsMigrations.ApplyToLibrary(39, presets, profiles));++ var ids = presets.Select(p => p.Id).ToList();+ Assert.Equal(ids.IndexOf("compress-pdf") + 1, ids.IndexOf("searchable-pdf"));+ Assert.True(presets.Single(p => p.Id == "searchable-pdf").Pdf.Ocr);- Assert.False(SettingsMigrations.ApplyToLibrary(39, presets, profiles));++ Assert.False(SettingsMigrations.ApplyToLibrary(40, presets, profiles));+ }+}