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
Prefer lossless routes after merging the engines
KnifeLemon016d6a5cbe81
diff --git a/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.cs b/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.csindex 7534e5d7..ee586cc7 100644--- a/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.cs+++ b/src/Filee.Engines/Hwp/Hwpx/DocumentReaders.cs@@ -72,6 +72,12 @@ internal static class DocumentReaders/// <summary>Formats read without any optional engine.</summary>public static IEnumerable<string> BuiltInFormats => BuiltIn.Keys;+ /// <summary>+ /// Extra cost of reading a PDF: its text is rebuilt from positioned words, so a route that keeps the source's own+ /// structure wins (HWP → HWPX → DOCX rather than HWP → PDF → DOCX), while PDF files themselves still convert.+ /// </summary>+ public const int PdfPenalty = 6;+/// <summary>Formats that need Pandoc (those without a built-in reader).</summary>public static IEnumerable<string> PandocFormats => ThroughPandoc.Keys.Where(f => !BuiltIn.ContainsKey(f));diff --git a/src/Filee.Engines/Hwp/Hwpx/HwpxConverter.cs b/src/Filee.Engines/Hwp/Hwpx/HwpxConverter.csindex 883f0d12..9c792470 100644--- a/src/Filee.Engines/Hwp/Hwpx/HwpxConverter.cs+++ b/src/Filee.Engines/Hwp/Hwpx/HwpxConverter.cs@@ -28,7 +28,7 @@ public sealed class HwpxConverter : IConverterpublic IReadOnlyList<ConversionEdge> Edges =>DocumentReaders.Formats(_pandoc ?? PandocConverter.Locate() is not null).Where(from => from != "hwpx") // HWPX is read only to write other formats (DOCX, HTML, EPUB, ...)- .Select(from => new ConversionEdge(from, "hwpx")).ToList();+ .Select(from => new ConversionEdge(from, "hwpx", from == "pdf" ? 10 + DocumentReaders.PdfPenalty : 10)).ToList();public EngineStatus GetStatus(){diff --git a/src/Filee.Engines/Office/DocxWriterConverter.cs b/src/Filee.Engines/Office/DocxWriterConverter.csindex a4ec81ce..0b2deb23 100644--- a/src/Filee.Engines/Office/DocxWriterConverter.cs+++ b/src/Filee.Engines/Office/DocxWriterConverter.cs@@ -23,7 +23,8 @@ public sealed class DocxWriterConverter : IConverterpublic int MaxParallelism => 0;public IReadOnlyList<ConversionEdge> Edges { get; } =- DocumentReaders.BuiltInFormats.Where(f => !WordFormats.Contains(f)).Select(f => new ConversionEdge(f, "docx", Cost)).ToList();+ DocumentReaders.BuiltInFormats.Where(f => !WordFormats.Contains(f))+ .Select(f => new ConversionEdge(f, "docx", f == "pdf" ? Cost + DocumentReaders.PdfPenalty : Cost)).ToList();public EngineStatus GetStatus() =>EngineStatus.Available(string.Join(", ", Edges.Select(e => e.From.ToUpperInvariant())) + " → DOCX", EngineVersions.BuiltIn);diff --git a/src/Filee.Engines/Office/SpreadsheetConverter.cs b/src/Filee.Engines/Office/SpreadsheetConverter.csindex fec814bf..7b0e0426 100644--- a/src/Filee.Engines/Office/SpreadsheetConverter.cs+++ b/src/Filee.Engines/Office/SpreadsheetConverter.cs@@ -20,7 +20,9 @@ public sealed class SpreadsheetConverter : IConverterpublic int MaxParallelism => 0;public IReadOnlyList<ConversionEdge> Edges { get; } =- [.. Sources.SelectMany(from => Targets.Where(to => to != from).Select(to => new ConversionEdge(from, to)))];+ // XLSM / XLTX → XLSX is left to the ooxml engine, which keeps the whole package instead of rewriting the sheets.+ [.. Sources.SelectMany(from => Targets.Where(to => to != from && !(to == "xlsx" && from is "xlsm" or "xltx"))+ .Select(to => new ConversionEdge(from, to)))];public EngineStatus GetStatus() =>EngineStatus.Available("XLSX, XLS, ODS, CSV, TSV → XLSX, ODS, CSV, TSV",diff --git a/tests/Filee.Engines.Tests/EbookTests.cs b/tests/Filee.Engines.Tests/EbookTests.csindex 0dc08c49..8045f04f 100644--- a/tests/Filee.Engines.Tests/EbookTests.cs+++ b/tests/Filee.Engines.Tests/EbookTests.cs@@ -57,8 +57,9 @@ public class EbookTests(EngineFixture fx) : IClassFixture<EngineFixture>{var planner = BuiltInPlanner("rhwp");- Assert.Equal(["ebook", "rhwp"], planner.Plan("epub", "pdf")!.Steps.Select(s => s.Converter.Id));- Assert.Equal(["ebook", "rhwp", "pdfium"], planner.Plan("mobi", "png")!.Steps.Select(s => s.Converter.Id));+ // E-book readers are also registered with the HWPX writer, which comes first in the default engine order.+ Assert.Equal(["hwpx-writer", "rhwp"], planner.Plan("epub", "pdf")!.Steps.Select(s => s.Converter.Id));+ Assert.Equal(["hwpx-writer", "rhwp", "pdfium"], planner.Plan("mobi", "png")!.Steps.Select(s => s.Converter.Id));foreach (var (from, to) in new[] { ("mobi", "epub"), ("azw3", "epub"), ("fb2", "epub"), ("epub", "fb2"), ("md", "epub"), ("docx", "epub"), ("epub", "txt"), ("cbr", "pdf"), ("pdf", "cbz"), ("azw4", "pdf"), ("htmlz", "txtz") })Assert.Equal("ebook", Assert.Single(planner.Plan(from, to)!.Steps).Converter.Id);Assert.Null(planner.Plan("epub", "mobi")); // needs calibrediff --git a/tests/Filee.Engines.Tests/GraphicsBuilders.cs b/tests/Filee.Engines.Tests/GraphicsBuilders.csindex a8bb5f24..06e9b46f 100644--- a/tests/Filee.Engines.Tests/GraphicsBuilders.cs+++ b/tests/Filee.Engines.Tests/GraphicsBuilders.cs@@ -320,13 +320,13 @@ internal static class GraphicsBuildersprivate static void DrawSample(IntPtr dc, int widthMm, int heightMm){- // Device units of the reference DC (the screen): convert millimetres with its resolution.- var pixelsX = GetDeviceCaps(dc, 88 /* LOGPIXELSX */) / 25.4;- var pixelsY = GetDeviceCaps(dc, 90 /* LOGPIXELSY */) / 25.4;- var w = (int)(widthMm * pixelsX);- var h = (int)(heightMm * pixelsY);- Fill(dc, 0, 0, w, h, 0x7F9E1D); // teal (COLORREF is 0x00BBGGRR)- Fill(dc, 0, 0, w / 3, h, 0x1E7FFF); // orange+ // Draw in 0.01 mm (MM_HIMETRIC, y grows upwards) so the picture fills the frame whatever screen the metafile is+ // recorded against: device units would follow the display's resolution and scaling at the time of the test.+ _ = SetMapMode(dc, 3 /* MM_HIMETRIC */);+ var w = widthMm * 100;+ var h = heightMm * 100;+ Fill(dc, 0, 0, w, -h, 0x7F9E1D); // teal (COLORREF is 0x00BBGGRR)+ Fill(dc, 0, 0, w / 3, -h, 0x1E7FFF); // orangestatic void Fill(IntPtr dc, int left, int top, int right, int bottom, uint color){@@ -349,6 +349,9 @@ internal static class GraphicsBuilders[DllImport("gdi32.dll")]private static extern IntPtr CloseEnhMetaFile(IntPtr dc);+ [DllImport("gdi32.dll")]+ private static extern int SetMapMode(IntPtr dc, int mode);+[DllImport("gdi32.dll")]private static extern bool DeleteEnhMetaFile(IntPtr metafile);