Skip to content

armgit / Filee

Public Imported from GitHub
0

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.

Merge origin/main: document formats, codecs and subtitles, more image formats, data and e-mail, 3D models (tracing settings migration is now schema 16)

KnifeLemon34f7daa3089e
diff --cc README.ko.md
index 8dac8572,c8a4d21c..75e2cac9
--- a/README.ko.md
+++ b/README.ko.md
@@@ -81,17 -81,18 +81,18 @@@
| 원본 | 변환 대상 |
|---|---|
- | **이미지**: JPG, PNG, WEBP, AVIF, TIFF, BMP, GIF, ICO, ICNS, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM, HEIC; GIMP XCF, 카메라 RAW(CR2, CR3, NEF, ARW, DNG 등)는 읽기 | 위 형식끼리(HEIC⁵), PDF, SVG(벡터화), 크기 조정, 흑백 |
- | **벡터**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG² | PDF(벡터), PNG 등 이미지, SVG ↔ SVGZ, SVG → DXF/DWG, PDF → EPS/PS¹ |
- | **PDF** | DOCX, HWPX, TXT, PNG, JPG, TIFF, CBZ; 합치기, 나누기, 페이지 범위 |
- | **문서**: DOCX, DOCM, DOTX, EML · DOC, ODT, RTF, WPS, WPD, Pages 등² | PDF, DOCX, HWPX, EPUB, TXT, HTML |
- | **스프레드시트**: XLSX, XLSM, XLS, ODS, CSV, TSV · Numbers, ET² | PDF, XLSX, ODS, CSV, TSV, HWPX, HTML |
- | **프레젠테이션**: PPTX, PPTM, POTX, PPSX · PPT, ODP, Keynote² | PDF, PNG, JPG, DOCX, HWPX |
-| **이미지**: JPG, PNG, WEBP, AVIF, TIFF, BMP, GIF, APNG, ICO, ICNS, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM, HEIC, QOI, DDS, PCX, MNG, CUR 등; GIMP XCF, 카메라 RAW(CR2, CR3, NEF, ARW, DNG 등), DICOM, OpenEXR, HDR은 읽기 | 위 형식끼리(HEIC⁵), PDF, 크기 조정, 흑백 |
-| **벡터**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG, FODG² | PDF(벡터), PNG 등 이미지, SVG ↔ SVGZ, PDF → EPS/PS¹, SVG → EMF, WMF, ODG² |
++| **이미지**: JPG, PNG, WEBP, AVIF, TIFF, BMP, GIF, APNG, ICO, ICNS, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM, HEIC, QOI, DDS, PCX, MNG, CUR 등; GIMP XCF, 카메라 RAW(CR2, CR3, NEF, ARW, DNG 등), DICOM, OpenEXR, HDR은 읽기 | 위 형식끼리(HEIC⁵), PDF, SVG(벡터화), 크기 조정, 흑백 |
++| **벡터**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG, FODG² | PDF(벡터), PNG 등 이미지, SVG ↔ SVGZ, SVG → DXF/DWG, PDF → EPS/PS¹, SVG → EMF, WMF, ODG² |
+ | **PDF** | DOCX, HWPX, TXT, PNG, JPG, TIFF, CBZ, SVG²; 합치기, 나누기, 페이지 범위 |
+ | **문서**: DOCX, DOCM, DOTX, EML, Outlook MSG · DOC, ODT, FODT, OTT, RTF, WPS, WPD, Pages, ClarisWorks, MacWrite, T602 등² | PDF, DOCX, HWPX, EPUB, TXT, HTML; MSG → EML · ODT, FODT, OTT² |
+ | **스프레드시트**: XLSX, XLSM, XLS, XLT, ODS, CSV, TSV · OTS, FODS, Numbers, ET² | PDF, XLSX, ODS, CSV, TSV, JSON, HWPX, HTML · XLT, OTS² |
+ | **프레젠테이션**: PPTX, PPTM, POTX, PPSX · PPT, ODP, OTP, FODP, Keynote² | PDF, PNG, JPG, DOCX, HWPX · OTP² |
| **한글**: HWP, HWPX | PDF, PNG, DOCX, HWPX ↔ HWP, TXT, 마크다운, HTML |
- | **텍스트**: TXT, 마크다운, HTML · reStructuredText, LaTeX³ | PDF, DOCX, HWPX, EPUB |
- | **전자책**: EPUB, MOBI, AZW3, AZW, AZW4, FB2, CBZ, CBR, CB7, HTMLZ, TXTZ · LIT, LRF, CHM, PDB 등⁴ | PDF, EPUB, DOCX, TXT, HTML, HWPX · MOBI, AZW3⁴ |
- | **동영상**⁵: MP4, MOV, MKV, WEBM, AVI, WMV, FLV, MPEG, TS, M2TS, 3GP, OGV, VOB 등 | MP4, WEBM, MOV, MKV, AVI, GIF, MP3, M4A, 720p |
- | **오디오**⁵: MP3, M4A, AAC, WAV, FLAC, OGG, OPUS, WMA, AIFF, AMR 등 | MP3, M4A, WAV, FLAC, OGG, OPUS, AAC |
+ | **텍스트**: TXT, 마크다운, HTML · reStructuredText, LaTeX, Org, AsciiDoc, Typst, MediaWiki, DocBook, Jupyter, Textile, man, OPML³ | PDF, DOCX, HWPX, EPUB · 서로 변환, PPTX 슬라이드³ |
+ | **전자책**: EPUB, KEPUB, MOBI, AZW3, AZW, AZW4, FB2, CBZ, CBR, CB7, HTMLZ, TXTZ · LIT, LRF, CHM, PDB 등⁴ | PDF, EPUB, KEPUB(코보), DOCX, TXT, HTML, HWPX · MOBI, AZW3⁴ |
+ | **동영상**⁵: MP4, MOV, MKV, WEBM, AVI, WMV, FLV, MPEG, TS, M2TS, 3GP, OGV, VOB 등 | MP4(H.264, HEVC, AV1), WEBM, MOV, MKV, AVI, GIF, APNG, MP3, M4A, 720p, 자막(SRT, ASS, WebVTT) |
+ | **오디오**⁵: MP3, M4A, AAC, WAV, FLAC, OGG, OPUS, WMA, AIFF, AMR, APE, WavPack, TTA, DSD(DSF, DFF), DTS, AC3, E-AC3 등 | MP3, M4A(AAC, ALAC), WAV, FLAC, OGG, OPUS, AAC, WavPack, TTA, W64, AC3, E-AC3 |
+ | **자막**: SRT, ASS/SSA, WebVTT, SAMI(SMI), LRC, TTML, MicroDVD, SCC | 서로 변환, UTF-8로 저장(CP949 한글 자막도 깨지지 않아요) |
| **압축 파일**: ZIP, 7Z, RAR, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, GZ, ISO, CAB, DMG, ALZ, EGG 등 | 압축 풀기, ZIP, 7Z, TAR, TAR.GZ; 여러 파일 → ZIP 하나 |
| **CAD**: DWG, DXF | PDF, SVG, PNG, DWG ↔ DXF |
| **글꼴**: TTF, OTF, WOFF, WOFF2, EOT | 서로 변환 |
diff --cc README.md
index f9a375b9,07de1952..08b5b981
--- a/README.md
+++ b/README.md
@@@ -81,17 -81,18 +81,18 @@@ Filee shows new releases in its menu an
| From | To |
|---|---|
- | **Images**: JPG, PNG, WEBP, AVIF, TIFF, BMP, GIF, ICO, ICNS, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM, HEIC; GIMP XCF, camera RAW (CR2, CR3, NEF, ARW, DNG, …) read | any of these (HEIC⁵), PDF, SVG (traced), resized, grayscale |
- | **Vector**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG² | PDF (vector), PNG and other images, SVG ↔ SVGZ, SVG → DXF/DWG, PDF → EPS/PS¹ |
- | **PDF** | DOCX, HWPX, TXT, PNG, JPG, TIFF, CBZ; merge, split, page ranges |
- | **Documents**: DOCX, DOCM, DOTX, EML · DOC, ODT, RTF, WPS, WPD, Pages, …² | PDF, DOCX, HWPX, EPUB, TXT, HTML |
- | **Spreadsheets**: XLSX, XLSM, XLS, ODS, CSV, TSV · Numbers, ET² | PDF, XLSX, ODS, CSV, TSV, HWPX, HTML |
- | **Presentations**: PPTX, PPTM, POTX, PPSX · PPT, ODP, Keynote² | PDF, PNG, JPG, DOCX, HWPX |
-| **Images**: JPG, PNG, WEBP, AVIF, TIFF, BMP, GIF, APNG, ICO, ICNS, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM, HEIC, QOI, DDS, PCX, MNG, CUR, …; GIMP XCF, camera RAW (CR2, CR3, NEF, ARW, DNG, …), DICOM, OpenEXR, HDR read | any of these (HEIC⁵), PDF, resized, grayscale |
-| **Vector**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG, FODG² | PDF (vector), PNG and other images, SVG ↔ SVGZ, PDF → EPS/PS¹, SVG → EMF, WMF, ODG² |
++| **Images**: JPG, PNG, WEBP, AVIF, TIFF, BMP, GIF, APNG, ICO, ICNS, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM, HEIC, QOI, DDS, PCX, MNG, CUR, …; GIMP XCF, camera RAW (CR2, CR3, NEF, ARW, DNG, …), DICOM, OpenEXR, HDR read | any of these (HEIC⁵), PDF, SVG (traced), resized, grayscale |
++| **Vector**: SVG, SVGZ, EMF, WMF, AI · EPS, PS¹ · CDR, VSD, CGM, ODG, FODG² | PDF (vector), PNG and other images, SVG ↔ SVGZ, SVG → DXF/DWG, PDF → EPS/PS¹, SVG → EMF, WMF, ODG² |
+ | **PDF** | DOCX, HWPX, TXT, PNG, JPG, TIFF, CBZ, SVG²; merge, split, page ranges |
+ | **Documents**: DOCX, DOCM, DOTX, EML, Outlook MSG · DOC, ODT, FODT, OTT, RTF, WPS, WPD, Pages, ClarisWorks, MacWrite, T602, …² | PDF, DOCX, HWPX, EPUB, TXT, HTML; MSG → EML · ODT, FODT, OTT² |
+ | **Spreadsheets**: XLSX, XLSM, XLS, XLT, ODS, CSV, TSV · OTS, FODS, Numbers, ET² | PDF, XLSX, ODS, CSV, TSV, JSON, HWPX, HTML · XLT, OTS² |
+ | **Presentations**: PPTX, PPTM, POTX, PPSX · PPT, ODP, OTP, FODP, Keynote² | PDF, PNG, JPG, DOCX, HWPX · OTP² |
| **HWP**: HWP, HWPX | PDF, PNG, DOCX, HWPX ↔ HWP, TXT, Markdown, HTML |
- | **Text**: TXT, Markdown, HTML · reStructuredText, LaTeX³ | PDF, DOCX, HWPX, EPUB |
- | **E-books**: EPUB, MOBI, AZW3, AZW, AZW4, FB2, CBZ, CBR, CB7, HTMLZ, TXTZ · LIT, LRF, CHM, PDB, …⁴ | PDF, EPUB, DOCX, TXT, HTML, HWPX · MOBI, AZW3⁴ |
- | **Video**⁵: MP4, MOV, MKV, WEBM, AVI, WMV, FLV, MPEG, TS, M2TS, 3GP, OGV, VOB, … | MP4, WEBM, MOV, MKV, AVI, GIF, MP3, M4A, 720p |
- | **Audio**⁵: MP3, M4A, AAC, WAV, FLAC, OGG, OPUS, WMA, AIFF, AMR, … | MP3, M4A, WAV, FLAC, OGG, OPUS, AAC |
+ | **Text**: TXT, Markdown, HTML · reStructuredText, LaTeX, Org, AsciiDoc, Typst, MediaWiki, DocBook, Jupyter, Textile, man, OPML³ | PDF, DOCX, HWPX, EPUB · each other, PPTX slides³ |
+ | **E-books**: EPUB, KEPUB, MOBI, AZW3, AZW, AZW4, FB2, CBZ, CBR, CB7, HTMLZ, TXTZ · LIT, LRF, CHM, PDB, …⁴ | PDF, EPUB, KEPUB (Kobo), DOCX, TXT, HTML, HWPX · MOBI, AZW3⁴ |
+ | **Video**⁵: MP4, MOV, MKV, WEBM, AVI, WMV, FLV, MPEG, TS, M2TS, 3GP, OGV, VOB, … | MP4 (H.264, HEVC, AV1), WEBM, MOV, MKV, AVI, GIF, APNG, MP3, M4A, 720p, subtitles (SRT, ASS, WebVTT) |
+ | **Audio**⁵: MP3, M4A, AAC, WAV, FLAC, OGG, OPUS, WMA, AIFF, AMR, APE, WavPack, TTA, DSD (DSF, DFF), DTS, AC3, E-AC3, … | MP3, M4A (AAC, ALAC), WAV, FLAC, OGG, OPUS, AAC, WavPack, TTA, W64, AC3, E-AC3 |
+ | **Subtitles**: SRT, ASS/SSA, WebVTT, SAMI (SMI), LRC, TTML, MicroDVD, SCC | each other as UTF-8 (Korean CP949 files read correctly) |
| **Archives**: ZIP, 7Z, RAR, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, GZ, ISO, CAB, DMG, ALZ, EGG, … | extract, ZIP, 7Z, TAR, TAR.GZ; any files → one ZIP |
| **CAD**: DWG, DXF | PDF, SVG, PNG, DWG ↔ DXF |
| **Fonts**: TTF, OTF, WOFF, WOFF2, EOT | each other |
diff --cc README.zh-CN.md
index f52f832f,efd2e96e..1760ad50
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@@ -80,17 -80,18 +80,18 @@@
| 源格式 | 目标格式 |
|---|---|
- | **图片**:JPG、PNG、WEBP、AVIF、TIFF、BMP、GIF、ICO、ICNS、JPEG XL、JPEG 2000、PSD/PSB、TGA、PPM、HEIC;GIMP XCF、相机 RAW(CR2、CR3、NEF、ARW、DNG 等)仅读取 | 上述格式互转(HEIC⁵)、PDF、SVG(描摹)、缩放、灰度 |
- | **矢量图**:SVG、SVGZ、EMF、WMF、AI · EPS、PS¹ · CDR、VSD、CGM、ODG² | PDF(矢量)、PNG 等图片、SVG ↔ SVGZ、SVG → DXF/DWG、PDF → EPS/PS¹ |
- | **PDF** | DOCX、HWPX、TXT、PNG、JPG、TIFF、CBZ;合并、拆分、页码范围 |
- | **文档**:DOCX、DOCM、DOTX、EML · DOC、ODT、RTF、WPS、WPD、Pages 等² | PDF、DOCX、HWPX、EPUB、TXT、HTML |
- | **表格**:XLSX、XLSM、XLS、ODS、CSV、TSV · Numbers、ET² | PDF、XLSX、ODS、CSV、TSV、HWPX、HTML |
- | **演示文稿**:PPTX、PPTM、POTX、PPSX · PPT、ODP、Keynote² | PDF、PNG、JPG、DOCX、HWPX |
-| **图片**:JPG、PNG、WEBP、AVIF、TIFF、BMP、GIF、APNG、ICO、ICNS、JPEG XL、JPEG 2000、PSD/PSB、TGA、PPM、HEIC、QOI、DDS、PCX、MNG、CUR 等;GIMP XCF、相机 RAW(CR2、CR3、NEF、ARW、DNG 等)、DICOM、OpenEXR、HDR 仅读取 | 上述格式互转(HEIC⁵)、PDF、缩放、灰度 |
-| **矢量图**:SVG、SVGZ、EMF、WMF、AI · EPS、PS¹ · CDR、VSD、CGM、ODG、FODG² | PDF(矢量)、PNG 等图片、SVG ↔ SVGZ、PDF → EPS/PS¹、SVG → EMF、WMF、ODG² |
++| **图片**:JPG、PNG、WEBP、AVIF、TIFF、BMP、GIF、APNG、ICO、ICNS、JPEG XL、JPEG 2000、PSD/PSB、TGA、PPM、HEIC、QOI、DDS、PCX、MNG、CUR 等;GIMP XCF、相机 RAW(CR2、CR3、NEF、ARW、DNG 等)、DICOM、OpenEXR、HDR 仅读取 | 上述格式互转(HEIC⁵)、PDF、SVG(描摹)、缩放、灰度 |
++| **矢量图**:SVG、SVGZ、EMF、WMF、AI · EPS、PS¹ · CDR、VSD、CGM、ODG、FODG² | PDF(矢量)、PNG 等图片、SVG ↔ SVGZ、SVG → DXF/DWG、PDF → EPS/PS¹、SVG → EMF、WMF、ODG² |
+ | **PDF** | DOCX、HWPX、TXT、PNG、JPG、TIFF、CBZ、SVG²;合并、拆分、页码范围 |
+ | **文档**:DOCX、DOCM、DOTX、EML、Outlook MSG · DOC、ODT、FODT、OTT、RTF、WPS、WPD、Pages、ClarisWorks、MacWrite、T602 等² | PDF、DOCX、HWPX、EPUB、TXT、HTML、MSG → EML · ODT、FODT、OTT² |
+ | **表格**:XLSX、XLSM、XLS、XLT、ODS、CSV、TSV · OTS、FODS、Numbers、ET² | PDF、XLSX、ODS、CSV、TSV、JSON、HWPX、HTML · XLT、OTS² |
+ | **演示文稿**:PPTX、PPTM、POTX、PPSX · PPT、ODP、OTP、FODP、Keynote² | PDF、PNG、JPG、DOCX、HWPX · OTP² |
| **HWP**:HWP、HWPX | PDF、PNG、DOCX、HWPX ↔ HWP、TXT、Markdown、HTML |
- | **文本**:TXT、Markdown、HTML · reStructuredText、LaTeX³ | PDF、DOCX、HWPX、EPUB |
- | **电子书**:EPUB、MOBI、AZW3、AZW、AZW4、FB2、CBZ、CBR、CB7、HTMLZ、TXTZ · LIT、LRF、CHM、PDB 等⁴ | PDF、EPUB、DOCX、TXT、HTML、HWPX · MOBI、AZW3⁴ |
- | **视频**⁵:MP4、MOV、MKV、WEBM、AVI、WMV、FLV、MPEG、TS、M2TS、3GP、OGV、VOB 等 | MP4、WEBM、MOV、MKV、AVI、GIF、MP3、M4A、720p |
- | **音频**⁵:MP3、M4A、AAC、WAV、FLAC、OGG、OPUS、WMA、AIFF、AMR 等 | MP3、M4A、WAV、FLAC、OGG、OPUS、AAC |
+ | **文本**:TXT、Markdown、HTML · reStructuredText、LaTeX、Org、AsciiDoc、Typst、MediaWiki、DocBook、Jupyter、Textile、man、OPML³ | PDF、DOCX、HWPX、EPUB · 互相转换、PPTX 幻灯片³ |
+ | **电子书**:EPUB、KEPUB、MOBI、AZW3、AZW、AZW4、FB2、CBZ、CBR、CB7、HTMLZ、TXTZ · LIT、LRF、CHM、PDB 等⁴ | PDF、EPUB、KEPUB(Kobo)、DOCX、TXT、HTML、HWPX · MOBI、AZW3⁴ |
+ | **视频**⁵:MP4、MOV、MKV、WEBM、AVI、WMV、FLV、MPEG、TS、M2TS、3GP、OGV、VOB 等 | MP4(H.264、HEVC、AV1)、WEBM、MOV、MKV、AVI、GIF、APNG、MP3、M4A、720p、字幕(SRT、ASS、WebVTT) |
+ | **音频**⁵:MP3、M4A、AAC、WAV、FLAC、OGG、OPUS、WMA、AIFF、AMR、APE、WavPack、TTA、DSD(DSF、DFF)、DTS、AC3、E-AC3 等 | MP3、M4A(AAC、ALAC)、WAV、FLAC、OGG、OPUS、AAC、WavPack、TTA、W64、AC3、E-AC3 |
+ | **字幕**:SRT、ASS/SSA、WebVTT、SAMI(SMI)、LRC、TTML、MicroDVD、SCC | 互相转换,保存为 UTF-8(也能读取 CP949 韩文字幕) |
| **压缩包**:ZIP、7Z、RAR、TAR、TAR.GZ、TAR.BZ2、TAR.XZ、GZ、ISO、CAB、DMG、ALZ、EGG 等 | 解压、ZIP、7Z、TAR、TAR.GZ;多个文件 → 一个 ZIP |
| **CAD**:DWG、DXF | PDF、SVG、PNG、DWG ↔ DXF |
| **字体**:TTF、OTF、WOFF、WOFF2、EOT | 互相转换 |
diff --cc docs/ENGINES.md
index cc1a0646,0fd7f2a0..6ed4dc63
--- a/docs/ENGINES.md
+++ b/docs/ENGINES.md
@@@ -5,8 -5,8 +5,8 @@@ Filee chooses engines automatically. Se
| Engine | How it gets there | Handles |
|---|---|---|
- | ImageMagick (Magick.NET) | built in (library) | JPG, PNG, WEBP, TIFF, BMP, GIF, ICO, AVIF, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM ↔ each other; HEIC (written with FFmpeg), XCF, camera RAW (LibRaw) and EMF/WMF (Windows) read |
+ | ImageMagick (Magick.NET) | built in (library) | JPG, PNG, WEBP, TIFF, BMP, GIF, ICO, AVIF, JPEG XL, JPEG 2000, PSD/PSB, TGA, PPM, MNG, QOI, DDS, PCX, CUR, XPM, XBM, WBMP, PAM, PFM, SGI, Sun Raster, MIFF ↔ each other, and **APNG** (Filee's own reader and writer); HEIC (written with FFmpeg), XCF, camera RAW (LibRaw), DICOM (uncompressed ones by Filee's own reader), Photo CD, OpenEXR, Radiance HDR and EMF/WMF (Windows) read |
-| Vector graphics | built in (Svg.Skia, SkiaSharp) | **SVG/SVGZ → PDF (vector) and images**, SVG ↔ SVGZ, PDF-compatible AI → PDF |
+| Vector graphics | built in (Svg.Skia, SkiaSharp, ACadSharp) | **SVG/SVGZ → PDF (vector) and images**, SVG ↔ SVGZ, **SVG → DXF** (→ DWG with the CAD engine), **raster images → SVG (tracing)**, PDF-compatible AI → PDF |
| ICNS | built in | images → ICNS (16–1024 px), ICNS → images |
| PDFsharp | built in (library) | images → PDF, merge, split, page ranges |
| PDFium | built in (library) | PDF → images (multi-page TIFF/GIF supported) |
@@@ -101,65 -140,6 +140,65 @@@ current
- EPS and PS → PNG go straight through Ghostscript's `pngalpha` device, so the background stays transparent;
JPG, WebP, … and AI reach images through PDF (Ghostscript → PDFium), and SVG reaches EPS through PDF.
+## Tracing (raster images → SVG)
+
+Built in (`Vector/Tracing`), no Potrace or other program: Filee's own code, written from published descriptions of the
+steps (no code of Potrace, AutoTrace or VTracer is used). Every raster format ImageMagick reads (PNG, JPG, BMP, GIF,
- WEBP, TIFF, HEIC, PSD, RAW, …) is traced, and other raster images through PNG (ICNS). Only raster images are traced:
++WEBP, TIFF, HEIC, PSD, RAW, DICOM, …) is traced, and other raster images through PNG (ICNS, APNG). Only raster images are traced:
+PDF, EPS, PS, AI, EMF/WMF, CDR, documents and videos are never redrawn from a rendering, so without a real vector
- route they have no SVG target. The first frame or page is used, turned upright, in sRGB. The SVG has the picture's pixel size
++route they have no SVG target (PDF → SVG, for example, needs LibreOffice). The first frame or page is used, turned upright, in sRGB. The SVG has the picture's pixel size
+(`width`/`height`/`viewBox` in pixels), so it lines up with the original.
+
+- **Black and white** (*Line art to SVG*: logos, signatures, scans): pixels darker than Otsu's threshold are ink
+ (transparent pixels count as white paper). On a transparent background the opaque pixels are the ink, or only their
+ darker part when the opaque area itself is light and dark. One black `<path>` on a transparent background.
+- **Colour** (*Trace to SVG*: illustrations, icons): k-means reduces the picture to the preset's number of colours
+ (2–64; run on the mean colours of 32 768 colour boxes weighted by their pixel counts, so it sees every pixel). One-pixel
+ bands of in-between colours along edges (anti-aliasing) join the colour on either side; regions smaller than a few
+ pixels (more on large pictures) join the neighbour they share most border with. Colours are stacked largest first,
+ and each colour's shape is the union of itself and every colour above it: lower shapes run under upper ones, so no
+ background shows through between neighbouring shapes. Transparent areas stay transparent. One `<path>` per colour.
+- **Outlines**: each shape's boundary is followed along the pixel edges (inside always on the right, so holes come out
+ reversed and fill correctly with the non-zero rule; pixels touching only at a corner stay one shape). Outlines
+ smaller than the speck size are dropped (and small holes filled).
+- **Curves**: the staircase is replaced by points on the edge it approximates (midpoints of the steps); corners are
+ kept where two long pixel runs meet, at the ends of thin lines, where the direction turns sharply within two
+ pixels, or where a gentler turn happens all at once (unlike a small circle). Points between corners are smoothed;
+ stretches that stay within half a pixel of a line without bending become lines; the rest becomes cubic Béziers
+ fitted by least squares (Philip J. Schneider, "An Algorithm for Automatically Fitting Digitized Curves", Graphics
+ Gems, 1990), meeting lines and each other with matching tangents.
+- **Options** (Settings → Presets): mode, colours (colour mode) and *Detail* 0–100. Low detail drops larger specks,
+ smooths more and allows the curves 1.15 px of deviation; high detail keeps every pixel's shape (0.25 px). The
+ default 50 drops specks under 6 px (black and white) or merges regions under 17 px (colour), at 0.7 px; speck and
+ region sizes grow with pictures larger than 1000 px (up to four times).
+- **Size and speed**: pictures over 6 megapixels or 4096 px on a side are reduced before tracing; the SVG keeps the
+ original size and says so in a comment. A 2000 × 2000 illustration traces in 1–3 s at 16 colours and well under a
+ second in black and white; a noisy 2000 × 2000 photo at 16 colours takes about 4 s (64 colours about 5 s, and a
+ 20 MB SVG). Photos are not what tracing is for: they come out as posterized patches.
+- **Routes**: tracing is the only raster → SVG route and costs 40 (`VectorConverter.TraceCost`), more than any route
+ from an image to a format SVG leads to, so it is never a step on the way to PDF, PNG, EPS, …; a test checks every
+ pair of formats. Its edges are marked `ImageSourcesOnly`: the planner uses them only when the file being
+ converted is a raster image (`FormatCategory.Image`), so a vector file rendered to PNG can't be traced; a test
+ checks this for every pair of formats too. Through SVG, pictures reach DXF and DWG.
+
+## SVG → DXF / DWG
+
+`Vector/SvgDxfWriter.cs` writes the drawing's outlines with ACadSharp (DXF, AutoCAD 2018 like the CAD engine; DWG is
+DXF → DWG by the CAD engine). The SVG is loaded with Svg.Skia as for PDF output, so groups, transforms, `<use>`,
+nested `<svg>`, CSS and text are resolved the same way.
+
+- Circles and ellipses become CIRCLE and ELLIPSE (also rotated, scaled or skewed: the transformed axes come from the
+ singular values of the transform). Paths, lines, polylines, polygons and rectangles (rounded too) become
+ LWPOLYLINEs, closed where the shape is closed, or a LINE for one straight segment. Bézier curves and arcs are divided
+ into straight pieces within 0.01 mm of the curve: every CAD and CAM program reads polylines, while SPLINE support
+ varies. Text becomes its glyph outlines.
+- Units: SVG user units are CSS pixels, 96 per inch, so 1 px = 25.4 / 96 mm and the DXF is in millimetres
+ (`$INSUNITS` 4, metric): a drawing 100 mm wide in the SVG is 100 mm wide in CAD. The y axis is flipped (SVG points
+ down, DXF up) with the viewport's bottom-left corner at (0, 0).
+- Colours are kept as true colours (the stroke's, else the fill's; black for gradients). Fills, stroke widths,
+ clipping, masks, images and filters are not represented; a shape both filled and stroked is written once. An SVG
+ with nothing to outline fails with a message.
+
## HWPX writer
Filee writes OWPML (HWPX) itself, so saving as HWPX needs no Hancom Office and shows no approval dialog.
diff --cc src/Filee.App/Assets/i18n/en.json
index ae1dda91,0b0f1f07..dddd5e47
--- a/src/Filee.App/Assets/i18n/en.json
+++ b/src/Filee.App/Assets/i18n/en.json
@@@ -71,8 -71,9 +71,9 @@@
"engine.hwpx-writer.description": "Writes HWPX from Word, Excel, PowerPoint, PDF, HTML, e-books and Markdown.\nThe first step of turning documents into PDF without Office.",
"engine.docx-writer.description": "Writes Word documents (DOCX) from PDF, HWP/HWPX, Markdown, HTML, spreadsheets, slides and e-books.",
"engine.pdf-text.description": "Extracts the text of PDFs in reading order, also from two-column pages (no OCR for scans).",
- "engine.email.description": "E-mails (EML) to HTML and text with sender, recipients and date, pictures included; attachments into a ZIP.",
+ "engine.email.description": "E-mails (EML, Outlook MSG) to HTML and text with sender, recipients and date, pictures included; attachments into a ZIP.\nMSG to EML.",
+ "engine.data.description": "JSON, JSON Lines, YAML, TOML, XML and CSV into each other.\nvCard contacts to CSV and back.\nComments are dropped. CSV holds tables only.",
- "engine.vector.description": "SVG and SVGZ to vector PDF and to images; Illustrator files saved with PDF content.",
+ "engine.vector.description": "SVG and SVGZ to vector PDF, images and DXF; pictures traced into SVG; Illustrator files saved with PDF content.",
"engine.icns.description": "macOS app icons (ICNS) from and to images.",
"engine.font.description": "Fonts: TTF, OTF, WOFF, WOFF2 and EOT into each other.",
"engine.cad.description": "AutoCAD drawings: DWG ↔ DXF, and both to PDF, SVG and PNG.",
@@@ -108,8 -114,7 +114,9 @@@
"preset.long_image": "Long image",
"preset.extract": "Extract",
"preset.zip_all": "One ZIP",
+ "preset.extract_subtitles": "Extract subtitles",
+ "preset.trace_svg": "Trace to SVG",
+ "preset.trace_line_art": "Line art to SVG",
"format.folder": "Folder",
"format.category.Image": "Image",
diff --cc src/Filee.App/Assets/i18n/ko.json
index 762b4dcb,fce89b71..a4989a51
--- a/src/Filee.App/Assets/i18n/ko.json
+++ b/src/Filee.App/Assets/i18n/ko.json
@@@ -71,8 -71,9 +71,9 @@@
"engine.hwpx-writer.description": "워드, 엑셀, 파워포인트, PDF, HTML, 전자책, 마크다운을 HWPX로 써요.\n오피스 없이 문서를 PDF로 바꾸는 첫 단계예요.",
"engine.docx-writer.description": "PDF, HWP/HWPX, 마크다운, HTML, 스프레드시트, 슬라이드, 전자책으로 워드 문서(DOCX)를 만들어요.",
"engine.pdf-text.description": "PDF의 글자를 읽는 순서대로 뽑아내요.\n2단 편집도 순서대로 읽어요(스캔 이미지 글자 인식은 안 해요).",
- "engine.email.description": "이메일(EML)을 보낸 사람·받는 사람·날짜와 본문 그림까지 담아 HTML·텍스트로 바꾸고, 첨부 파일은 ZIP으로 모아요.",
+ "engine.email.description": "이메일(EML, Outlook MSG)을 보낸 사람·받는 사람·날짜와 본문 그림까지 담아 HTML·텍스트로 바꾸고, 첨부 파일은 ZIP으로 모아요.\nMSG는 EML로도 바꿔요.",
+ "engine.data.description": "JSON, JSON Lines, YAML, TOML, XML, CSV를 서로 바꿔요.\nvCard 연락처를 CSV로, CSV를 vCard로 바꿔요.\n주석은 빠져요. CSV는 표 모양 데이터만 담아요.",
- "engine.vector.description": "SVG·SVGZ를 벡터 PDF와 이미지로, PDF 내용이 들어 있는 일러스트레이터 파일도 변환해요.",
+ "engine.vector.description": "SVG·SVGZ를 벡터 PDF, 이미지, DXF로 바꾸고 그림을 SVG로 벡터화해요. PDF 내용이 들어 있는 일러스트레이터 파일도 변환해요.",
"engine.icns.description": "macOS 앱 아이콘(ICNS)을 이미지로, 이미지를 ICNS로.",
"engine.font.description": "글꼴: TTF, OTF, WOFF, WOFF2, EOT를 서로 변환해요.",
"engine.cad.description": "오토캐드 도면: DWG ↔ DXF, 그리고 둘 다 PDF, SVG, PNG로.",
@@@ -108,8 -114,7 +114,9 @@@
"preset.long_image": "긴 이미지",
"preset.extract": "압축 풀기",
"preset.zip_all": "ZIP 하나로",
+ "preset.extract_subtitles": "자막 추출",
+ "preset.trace_svg": "벡터화",
+ "preset.trace_line_art": "흑백 선화",
"format.folder": "폴더",
"format.category.Image": "이미지",
diff --cc src/Filee.App/Assets/i18n/zh-CN.json
index d7ed4de7,e0ad99db..91356389
--- a/src/Filee.App/Assets/i18n/zh-CN.json
+++ b/src/Filee.App/Assets/i18n/zh-CN.json
@@@ -71,8 -71,9 +71,9 @@@
"engine.hwpx-writer.description": "把 Word、Excel、PowerPoint、PDF、HTML、电子书和 Markdown 写成 HWPX。\n这是不用 Office 把文档转为 PDF 的第一步。",
"engine.docx-writer.description": "用 PDF、HWP/HWPX、Markdown、HTML、表格、幻灯片和电子书生成 Word 文档(DOCX)。",
"engine.pdf-text.description": "按阅读顺序提取 PDF 中的文字,双栏页面也能正确排序(不对扫描件做文字识别)。",
- "engine.email.description": "将电子邮件(EML)连同发件人、收件人、日期和图片转为 HTML 和文本,附件打包为 ZIP。",
+ "engine.email.description": "将电子邮件(EML、Outlook MSG)连同发件人、收件人、日期和图片转为 HTML 和文本,附件打包为 ZIP。\nMSG 也可转为 EML。",
+ "engine.data.description": "JSON、JSON Lines、YAML、TOML、XML、CSV 互相转换。\nvCard 联系人与 CSV 互转。\n注释不保留。CSV 仅支持表格数据。",
- "engine.vector.description": "将 SVG、SVGZ 转为矢量 PDF 和图片;也支持包含 PDF 内容的 Illustrator 文件。",
+ "engine.vector.description": "将 SVG、SVGZ 转为矢量 PDF、图片和 DXF,并可将图片描摹为 SVG。也支持包含 PDF 内容的 Illustrator 文件。",
"engine.icns.description": "macOS 应用图标(ICNS)与图片互转。",
"engine.font.description": "字体:TTF、OTF、WOFF、WOFF2 和 EOT 互相转换。",
"engine.cad.description": "AutoCAD 图纸:DWG ↔ DXF,并可转为 PDF、SVG 和 PNG。",
@@@ -108,8 -114,7 +114,9 @@@
"preset.long_image": "长图",
"preset.extract": "解压",
"preset.zip_all": "打包成一个 ZIP",
+ "preset.extract_subtitles": "提取字幕",
+ "preset.trace_svg": "描摹",
+ "preset.trace_line_art": "黑白描摹",
"format.folder": "文件夹",
"format.category.Image": "图片",
diff --cc src/Filee.App/ViewModels/PresetEditorViewModel.cs
index d8c6503d,ff9a2edd..09272bd2
--- a/src/Filee.App/ViewModels/PresetEditorViewModel.cs
+++ b/src/Filee.App/ViewModels/PresetEditorViewModel.cs
@@@ -88,11 -87,10 +88,13 @@@ public sealed partial class PresetEdito
_audioChannels = AudioChannelChoices.FirstOrDefault(c => c.Value == _edit.Media.AudioChannels) ?? AudioChannelChoices[0];
_sampleRate = SampleRates.First(r => r.Value == _edit.Media.AudioSampleRate);
_wavFormat = WavFormats.First(f => f.Value == _edit.Media.WavFormat);
+ _videoCodecValue = _edit.Media.VideoCodec;
+ _audioCodecValue = _edit.Media.AudioCodec;
_archiveLevel = ArchiveLevels.First(l => l.Value == _edit.Archive.Level);
_combineIntoOne = _edit.Archive.CombineIntoOne;
+ _traceMode = TraceModes.First(m => m.Value == _edit.Trace.Mode);
+ _traceColors = Math.Clamp(_edit.Trace.Colors, TracingOptions.MinColors, TracingOptions.MaxColors);
+ _traceDetail = Math.Clamp(_edit.Trace.Detail, 0, 100);
_quality = _edit.Image.Quality;
_resizePercent = _edit.Image.ResizePercent;
_longEdge = _edit.Image.LongEdge;
@@@ -148,10 -145,57 +150,57 @@@
[NotifyPropertyChangedFor(nameof(ShowImage), nameof(ShowQuality), nameof(ShowTiff), nameof(ShowMultiPageTiff), nameof(ShowWebp), nameof(ShowIco),
nameof(ShowPdf), nameof(ShowPdfBuild), nameof(ShowDocument), nameof(ShowPdfSplit), nameof(ShowPdfCombine),
nameof(ShowMedia), nameof(ShowMediaQuality), nameof(ShowMaxHeight), nameof(ShowAudioBitrate), nameof(ShowRemoveAudio),
- nameof(ShowAudioChannels), nameof(ShowWav),
+ nameof(ShowAudioChannels), nameof(ShowWav), nameof(VideoCodecs), nameof(VideoCodecChoice), nameof(ShowVideoCodec),
+ nameof(AudioCodecs), nameof(AudioCodecChoice), nameof(ShowAudioCodec),
- nameof(ShowArchive), nameof(ShowArchiveOptions), nameof(ShowExtractNote))]
+ nameof(ShowArchive), nameof(ShowArchiveOptions), nameof(ShowExtractNote), nameof(ShowTrace))]
private Choice<string> _target;
+ private VideoCodec _videoCodecValue;
+ private AudioCodec _audioCodecValue;
+
+ /// <summary>The video codecs the target can hold (H.264 / VP9, HEVC, AV1); one entry for most targets.</summary>
+ public IReadOnlyList<Choice<VideoCodec>> VideoCodecs =>
+ [.. MediaCodecs.VideoCodecsFor(TargetId).Select(c => new Choice<VideoCodec>(c, _loc[c switch
+ {
+ VideoCodec.Hevc => "presets.video_codec.hevc",
+ VideoCodec.Av1 => "presets.video_codec.av1",
+ _ => TargetId == "webm" ? "presets.video_codec.vp9" : "presets.video_codec.h264",
+ }]))];
+
+ /// <summary>The chosen video codec; a codec the target can't hold shows (and is saved) as its usual one.</summary>
+ public Choice<VideoCodec> VideoCodecChoice
+ {
+ get => VideoCodecs.FirstOrDefault(c => c.Value == _videoCodecValue) ?? VideoCodecs[0];
+ set
+ {
+ // The combo box clears its selection while its list is replaced.
+ if (value is null || value.Value == _videoCodecValue)
+ return;
+ _videoCodecValue = value.Value;
+ OnPropertyChanged();
+ }
+ }
+
+ /// <summary>The audio codecs the target can hold (AAC or ALAC for M4A); one entry for most targets.</summary>
+ public IReadOnlyList<Choice<AudioCodec>> AudioCodecs =>
+ [.. MediaCodecs.AudioCodecsFor(TargetId).Select(c => new Choice<AudioCodec>(c, _loc[c == AudioCodec.Alac ? "presets.audio_codec.alac" : "presets.audio_codec.aac"]))];
+
+ /// <summary>The chosen audio codec; ALAC is lossless, so it has no quality or bitrate.</summary>
+ public Choice<AudioCodec> AudioCodecChoice
+ {
+ get => AudioCodecs.FirstOrDefault(c => c.Value == _audioCodecValue) ?? AudioCodecs[0];
+ set
+ {
+ if (value is null || value.Value == _audioCodecValue)
+ return;
+ _audioCodecValue = value.Value;
+ OnPropertyChanged();
+ OnPropertyChanged(nameof(ShowMediaQuality));
+ OnPropertyChanged(nameof(ShowAudioBitrate));
+ OnPropertyChanged(nameof(ShowMedia));
+ }
+ }
+
[ObservableProperty, NotifyPropertyChangedFor(nameof(ShowPercent), nameof(ShowLongEdge), nameof(ShowWidth))]
private Choice<ResizeMode> _resize;
@@@ -336,11 -375,10 +392,13 @@@
media.AudioChannels = AudioChannels.Value;
media.AudioSampleRate = SampleRate.Value;
media.WavFormat = WavFormat.Value;
+ media.VideoCodec = MediaCodecs.Effective(TargetId, _videoCodecValue);
+ media.AudioCodec = MediaCodecs.Effective(TargetId, _audioCodecValue);
_original.Archive.Level = ArchiveLevel.Value;
_original.Archive.CombineIntoOne = CombineIntoOne;
+ _original.Trace.Mode = TraceMode.Value;
+ _original.Trace.Colors = Math.Clamp(TraceColors, TracingOptions.MinColors, TracingOptions.MaxColors);
+ _original.Trace.Detail = Math.Clamp(TraceDetail, 0, 100);
var output = _original.Output;
output.Location = Location.Value;
diff --cc src/Filee.Core/Presets/BuiltInData.cs
index 6d0f7d2e,404f9433..bb11ebab
--- a/src/Filee.Core/Presets/BuiltInData.cs
+++ b/src/Filee.Core/Presets/BuiltInData.cs
@@@ -74,20 -74,39 +74,51 @@@ public static class BuiltInDat
new() { Id = "to-html", Name = "HTML", TargetFormat = "html" },
.. SpreadsheetPresets(),
.. CatalogPresets(),
+ .. DataPresets(),
+ .. CodecAndSubtitlePresets(),
+ .. ModelPresets(),
+ .. TracePresets(),
+ ];
+
- /// <summary>Raster → SVG tracing, in colour and as black line art (added in settings schema 11).</summary>
++ /// <summary>Raster → SVG tracing, in colour and as black line art (added in settings schema 16).</summary>
+ public static List<Preset> TracePresets() =>
+ [
+ new() { Id = "trace-svg", NameKey = "preset.trace_svg", TargetFormat = "svg" },
+ new()
+ {
+ Id = "trace-line-art", NameKey = "preset.trace_line_art", TargetFormat = "svg",
+ Trace = { Mode = TracingMode.BlackAndWhite },
+ },
];
+ /// <summary>
+ /// HEVC / AV1 video, ALAC and the subtitle targets (added in settings schema 11, see SettingsMigrations).
+ /// </summary>
+ public static List<Preset> CodecAndSubtitlePresets() =>
+ [
+ // Video codecs and lossless audio
+ new()
+ {
+ Id = "mp4-hevc", Name = "MP4 HEVC", TargetFormat = "mp4",
+ Media = { VideoCodec = VideoCodec.Hevc }, Output = { FileNamePattern = "{name}_hevc" },
+ },
+ new()
+ {
+ Id = "mp4-av1", Name = "MP4 AV1", TargetFormat = "mp4",
+ Media = { VideoCodec = VideoCodec.Av1 }, Output = { FileNamePattern = "{name}_av1" },
+ },
+ new() { Id = "to-alac", Name = "ALAC", TargetFormat = "m4a", Media = { AudioCodec = AudioCodec.Alac } },
+
+ // Subtitles; on the video donut, SRT takes the first text subtitle track out of the video.
+ new() { Id = "extract-subtitles", NameKey = "preset.extract_subtitles", TargetFormat = "srt" },
+ new() { Id = "to-srt", Name = "SRT", TargetFormat = "srt" },
+ new() { Id = "to-vtt", Name = "WebVTT", TargetFormat = "vtt" },
+ new() { Id = "to-ass", Name = "ASS", TargetFormat = "ass" },
+ new() { Id = "to-smi", Name = "SAMI", TargetFormat = "smi" },
+ new() { Id = "to-lrc", Name = "LRC", TargetFormat = "lrc" },
+ new() { Id = "to-ttml", Name = "TTML", TargetFormat = "ttml" },
+ ];
+
/// <summary>HWP as a target, through HWPX (added in settings schema 7, see SettingsMigrations).</summary>
public static List<Preset> HwpPresets() =>
[
diff --cc src/Filee.Core/Settings/AppSettings.cs
index 4df29b84,6af60ecf..89e3ccfa
--- a/src/Filee.Core/Settings/AppSettings.cs
+++ b/src/Filee.Core/Settings/AppSettings.cs
@@@ -50,7 -50,7 +50,7 @@@ public sealed class DonutSetting
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
- public const int CurrentSchemaVersion = 11;
- public const int CurrentSchemaVersion = 15;
++ public const int CurrentSchemaVersion = 16;
public int SchemaVersion { get; set; } = CurrentSchemaVersion;
diff --cc src/Filee.Core/Settings/UserDataStore.cs
index 4b3a18ee,5d14774c..0c9228ad
--- a/src/Filee.Core/Settings/UserDataStore.cs
+++ b/src/Filee.Core/Settings/UserDataStore.cs
@@@ -361,18 -386,39 +386,52 @@@ internal static class SettingsMigration
changed = true;
}
- // v11: raster → SVG tracing ("Trace to SVG" in colour, "Line art to SVG" in black), on the images donut after
- // PDF.
+ // v11: more document formats (Org, AsciiDoc, Typst, ... through Pandoc; flat OpenDocument, templates,
+ // ClarisWorks, ... through LibreOffice; KEPUB built in). Built-in donuts learn the new extensions unless
+ // another donut already has them, and the e-books donut gets KEPUB after MOBI.
if (from < 11)
+ {
+ if (presets.All(p => p.Id != "to-kepub"))
+ {
+ presets.Add(BuiltInData.CreatePresets().Single(p => p.Id == "to-kepub"));
+ changed = true;
+ changed |= Offer(presets, profiles, "ebooks", "to-kepub", "to-mobi");
+ }
+ changed |= LearnExtensions(profiles, out _);
+ }
+
+ // v12: HEVC / AV1 video, ALAC and the new audio formats (WavPack, TTA, APE, DSD, ...), and a subtitles donut
+ // after the audio donut. The video donut offers "MP4 HEVC" and "Extract subtitles".
+ if (from < 12)
+ changed |= AddCodecsAndSubtitles(presets, profiles);
+
+ // v13: more image formats (APNG, MNG, QOI, DDS, DICOM, OpenEXR, …, Fujifilm's .hif): the images donut learns
+ // their extensions unless another donut already has them.
+ if (from < 13)
+ changed |= LearnExtensions(profiles, out _);
+
+ // v14: structured data (JSON, YAML, TOML, XML, vCard) gets its own donut after "fonts", Outlook MSG joins
+ // the documents donut next to EML, and the spreadsheets donut gets JSON after CSV.
+ if (from < 14)
+ changed |= AddData(presets, profiles);
+
+ // v15: 3D models (GLB, glTF, STL, OBJ, 3MF, PLY) get presets and their own donut after "data" (else after
+ // "fonts", else before the mixed-files one), with the extensions no donut of the user takes yet.
+ if (from < 15)
+ changed |= AddModels(presets, profiles);
++
++ // v16: raster → SVG tracing ("Trace to SVG" in colour, "Line art to SVG" in black), on the images donut after
++ // PDF.
++ if (from < 16)
+ {
+ foreach (var preset in BuiltInData.TracePresets().Where(p => presets.All(existing => existing.Id != p.Id)))
+ {
+ presets.Add(preset);
+ changed = true;
+ }
+ changed |= Offer(presets, profiles, "images", "trace-svg", "to-pdf");
+ changed |= Offer(presets, profiles, "images", "trace-line-art", "trace-svg");
+ }
return changed;
}
diff --cc tests/Filee.Core.Tests/UserDataStoreTests.cs
index 78ecd888,1ce4ce8c..68d77bcf
--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs
+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs
@@@ -211,42 -215,170 +215,207 @@@ public class UserDataStoreTest
}
[Fact]
- public void Version_10_libraries_get_the_tracing_presets_on_the_images_donut_after_pdf()
+ public void Version_13_libraries_get_the_data_donut_msg_files_and_json_for_spreadsheets()
+ {
+ // As written with schema 13: no data presets or donut, no MSG on the documents donut, no JSON on the spreadsheets
+ // donut; and a donut of the user that already takes YAML.
+ var presets = BuiltInData.CreatePresets();
+ presets.RemoveAll(p => BuiltInData.DataPresets().Any(d => d.Id == p.Id));
+ var profiles = BuiltInData.CreateProfiles();
+ profiles.RemoveAll(p => p.Id == "data");
+ profiles.Single(p => p.Id == "office").Extensions.Remove("msg");
+ profiles.Single(p => p.Id == "spreadsheets").PresetIds.Remove("to-json");
+ profiles.Insert(0, new ToolbarProfile { Id = "mine", Name = "Mine", Extensions = ["yml"] });
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(13, presets, profiles));
+
+ Assert.All(BuiltInData.DataPresets(), d => Assert.Contains(presets, p => p.Id == d.Id));
+ var ids = profiles.Select(p => p.Id).ToList();
+ Assert.Equal(ids.IndexOf("fonts") + 1, ids.IndexOf("data"));
+ var data = profiles.Single(p => p.Id == "data");
+ Assert.Contains("json", data.Extensions);
+ Assert.Contains("yaml", data.Extensions);
+ Assert.DoesNotContain("yml", data.Extensions); // the user's donut keeps it
+ Assert.Equal(["to-json", "to-yaml", "to-toml", "to-xml", "to-csv", "to-xlsx"], data.PresetIds);
+ Assert.Contains("msg", profiles.Single(p => p.Id == "office").Extensions);
+ var sheets = profiles.Single(p => p.Id == "spreadsheets").PresetIds;
+ Assert.Equal(sheets.IndexOf("to-csv") + 1, sheets.IndexOf("to-json"));
+ Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("to-eml") || p.PresetIds.Contains("to-vcf"));
+ Assert.False(SettingsMigrations.ApplyToLibrary(13, presets, profiles)); // once only
+
+ var all = profiles.SelectMany(p => p.Extensions).ToList();
+ Assert.Equal(all.Count, all.Distinct(StringComparer.OrdinalIgnoreCase).Count());
+ }
+
+ [Fact]
+ public void Version_13_settings_get_the_data_engine_after_email()
+ {
+ using var dir = new TempDir();
+ File.WriteAllText(Path.Combine(dir.Path, "settings.json"),
+ """{ "schemaVersion": 13, "enginePriority": ["magick", "email", "vector", "pandoc", "libreoffice"] }""");
+
+ var store = new UserDataStore(dir.Path);
+ store.Load();
+
+ // ... and, from schema 15, the 3D model engine before Pandoc (no CAD or archive engine in this list).
+ Assert.Equal(["magick", "email", "data", "vector", "model3d", "pandoc", "libreoffice"], store.Settings.EnginePriority);
+ }
+
+ [Fact]
+ public void Version_12_libraries_open_the_new_image_formats_on_the_images_donut()
+ {
+ // As written with schema 12: the images donut knows no APNG, QOI, DICOM or .hif; a donut of the user takes DDS.
+ var presets = BuiltInData.CreatePresets();
+ var profiles = BuiltInData.CreateProfiles();
+ var images = profiles.Single(p => p.Id == "images");
+ images.Extensions.RemoveAll(e => e is "apng" or "qoi" or "dcm" or "hif" or "dds");
+ profiles.Insert(0, new ToolbarProfile { Id = "game", Name = "Game textures", Extensions = ["dds"] });
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(12, presets, profiles));
+
+ Assert.Contains("apng", images.Extensions);
+ Assert.Contains("qoi", images.Extensions);
+ Assert.Contains("dcm", images.Extensions);
+ Assert.Contains("hif", images.Extensions);
+ Assert.DoesNotContain("dds", images.Extensions);
+ Assert.False(SettingsMigrations.ApplyToLibrary(12, presets, profiles)); // once only
+ }
+
+ [Fact]
+ public void Version_11_libraries_get_codecs_new_audio_formats_and_a_subtitles_donut()
+ {
+ // As written with schema 11: no HEVC / AV1 / ALAC / subtitle presets, no subtitles donut, the video donut and
+ // the audio extensions of that time, and a donut of the user that already takes .ape.
+ var added = BuiltInData.CodecAndSubtitlePresets().Select(p => p.Id).ToHashSet();
+ var presets = BuiltInData.CreatePresets().Where(p => !added.Contains(p.Id)).ToList();
+ var profiles = BuiltInData.CreateProfiles().Where(p => p.Id != "subtitles").ToList();
+ foreach (var profile in profiles)
+ profile.PresetIds.RemoveAll(added.Contains);
+ var audio = profiles.Single(p => p.Id == "audio");
+ audio.Extensions.RemoveAll(e => e is "wv" or "tta" or "w64" or "eac3" or "ec3" or "ape" or "mpc" or "mpp" or "mp+" or "tak"
+ or "dsf" or "dff" or "dts" or "spx");
+ profiles.Insert(0, new ToolbarProfile { Id = "mine", Name = "Mine", Extensions = ["ape"] });
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(11, presets, profiles));
+
+ Assert.Contains("wv", audio.Extensions);
+ Assert.Contains("dsf", audio.Extensions);
+ Assert.DoesNotContain("ape", audio.Extensions); // the user's donut keeps it
+ var ids = profiles.Select(p => p.Id).ToList();
+ Assert.Equal(ids.IndexOf("audio") + 1, ids.IndexOf("subtitles"));
+ Assert.Equal(BuiltInData.SubtitleProfile().PresetIds, profiles.Single(p => p.Id == "subtitles").PresetIds);
+ Assert.Contains("smi", profiles.Single(p => p.Id == "subtitles").Extensions);
+ Assert.Equal(BuiltInData.CreateProfiles().Single(p => p.Id == "video").PresetIds, profiles.Single(p => p.Id == "video").PresetIds);
+ Assert.Equal(VideoCodec.Hevc, presets.Single(p => p.Id == "mp4-hevc").Media.VideoCodec);
+ Assert.Equal(AudioCodec.Alac, presets.Single(p => p.Id == "to-alac").Media.AudioCodec);
+ Assert.DoesNotContain(profiles, p => p.PresetIds.Contains("to-alac") || p.PresetIds.Contains("mp4-av1"));
+ var all = profiles.SelectMany(p => p.Extensions).ToList();
+ Assert.Equal(all.Count, all.Distinct(StringComparer.OrdinalIgnoreCase).Count());
+ Assert.False(SettingsMigrations.ApplyToLibrary(11, presets, profiles)); // once only
+ }
+
+ [Fact]
+ public void Version_10_libraries_get_kepub_and_the_new_document_extensions()
+ {
+ // As written by 1.11.x: no KEPUB preset, and the donuts without the formats added in schema 11.
+ string[] added = ["org", "adoc", "typ", "mediawiki", "wiki", "dbk", "ipynb", "fodt", "ott", "cwk", "602", "ots", "fods", "otp", "fodp", "fodg", "kepub.epub"];
+ var presets = BuiltInData.CreatePresets();
+ presets.RemoveAll(p => p.Id == "to-kepub");
+ var profiles = BuiltInData.CreateProfiles();
+ foreach (var profile in profiles)
+ {
+ profile.PresetIds.Remove("to-kepub");
+ profile.Extensions.RemoveAll(added.Contains);
+ }
+ // A donut of the user already handles Org files.
+ profiles.Insert(0, new ToolbarProfile { Id = "mine", Name = "Mine", Extensions = ["org"] });
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(10, presets, profiles));
+
+ Assert.Equal("kepub", presets.Single(p => p.Id == "to-kepub").TargetFormat);
+ var ebooks = profiles.Single(p => p.Id == "ebooks");
+ Assert.Equal(ebooks.PresetIds.IndexOf("to-mobi") + 1, ebooks.PresetIds.IndexOf("to-kepub"));
+ Assert.Contains("kepub.epub", ebooks.Extensions);
+ Assert.Contains("typ", profiles.Single(p => p.Id == "text").Extensions);
+ Assert.DoesNotContain("org", profiles.Single(p => p.Id == "text").Extensions);
+ Assert.Contains("fodt", profiles.Single(p => p.Id == "office").Extensions);
+ Assert.Contains("fods", profiles.Single(p => p.Id == "spreadsheets").Extensions);
+ Assert.Contains("otp", profiles.Single(p => p.Id == "presentations").Extensions);
+ Assert.Contains("fodg", profiles.Single(p => p.Id == "vector").Extensions);
+ foreach (var expected in BuiltInData.CreateProfiles())
+ Assert.Equal(expected.PresetIds, profiles.Single(p => p.Id == expected.Id).PresetIds);
+ Assert.False(SettingsMigrations.ApplyToLibrary(10, presets, profiles)); // once only
+ }
+
+ [Fact]
+ public void Version_14_libraries_get_3d_model_presets_and_their_donut_after_data()
+ {
+ // As written with schema 14: no 3D formats.
+ var modelIds = BuiltInData.ModelPresets().Select(p => p.Id).ToHashSet();
+ var presets = BuiltInData.CreatePresets().Where(p => !modelIds.Contains(p.Id)).ToList();
+ var profiles = BuiltInData.CreateProfiles().Where(p => p.Id != "models").ToList();
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(14, presets, profiles));
+
+ Assert.Equal(["to-glb", "to-stl", "to-obj", "to-3mf", "to-ply", "to-gltf"], presets.Where(p => modelIds.Contains(p.Id)).Select(p => p.Id));
+ var ids = profiles.Select(p => p.Id).ToList();
+ Assert.Equal(ids.IndexOf("data") + 1, ids.IndexOf("models"));
+ Assert.Equal(ids.IndexOf("mixed") - 1, ids.IndexOf("models"));
+ var models = profiles.Single(p => p.Id == "models");
+ Assert.Equal(["glb", "gltf", "stl", "obj", "3mf", "ply"], models.Extensions);
+ Assert.Equal(BuiltInData.ModelProfile().PresetIds, models.PresetIds);
+ Assert.False(SettingsMigrations.ApplyToLibrary(14, presets, profiles)); // once only
+ }
+
+ [Fact]
+ public void The_3d_donut_leaves_out_extensions_a_profile_of_the_user_takes()
+ {
+ var presets = BuiltInData.CreatePresets();
+ var profiles = BuiltInData.CreateProfiles().Where(p => p.Id != "models").ToList();
+ profiles.Insert(0, new ToolbarProfile { Id = "printing", Name = "Printing", Extensions = ["stl", "3mf"] });
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(14, presets, profiles));
+
+ Assert.Equal(["glb", "gltf", "obj", "ply"], profiles.Single(p => p.Id == "models").Extensions);
+ }
+
++ [Fact]
++ public void Version_15_libraries_get_the_tracing_presets_on_the_images_donut_after_pdf()
+ {
+ // As written before tracing: no trace presets, and the images donut without them.
+ var presets = BuiltInData.CreatePresets();
+ presets.RemoveAll(p => p.Id is "trace-svg" or "trace-line-art");
+ var profiles = BuiltInData.CreateProfiles();
+ var images = profiles.Single(p => p.Id == "images");
+ images.PresetIds.RemoveAll(id => id is "trace-svg" or "trace-line-art");
+
- Assert.True(SettingsMigrations.ApplyToLibrary(10, presets, profiles));
++ Assert.True(SettingsMigrations.ApplyToLibrary(15, presets, profiles));
+
+ Assert.Equal(TracingMode.Color, presets.Single(p => p.Id == "trace-svg").Trace.Mode);
+ Assert.Equal(TracingMode.BlackAndWhite, presets.Single(p => p.Id == "trace-line-art").Trace.Mode);
+ Assert.All(presets.Where(p => p.Id.StartsWith("trace-", StringComparison.Ordinal)), p => Assert.Equal("svg", p.TargetFormat));
+ Assert.Equal(BuiltInData.CreateProfiles().Single(p => p.Id == "images").PresetIds, images.PresetIds);
- Assert.False(SettingsMigrations.ApplyToLibrary(10, presets, profiles)); // once only
++ Assert.False(SettingsMigrations.ApplyToLibrary(15, presets, profiles)); // once only
+ }
+
+ [Fact]
+ public void Trace_options_survive_a_save_and_load()
+ {
+ using var dir = new TempDir();
+ var store = new UserDataStore(dir.Path);
+ store.Load();
+ var preset = store.Presets.Single(p => p.Id == "trace-svg");
+ preset.Trace.Colors = 6;
+ preset.Trace.Detail = 80;
+ store.SaveLibrary();
+
+ var reloaded = new UserDataStore(dir.Path);
+ reloaded.Load();
+ var trace = reloaded.Presets.Single(p => p.Id == "trace-svg").Trace;
+ Assert.Equal((TracingMode.Color, 6, 80), (trace.Mode, trace.Colors, trace.Detail));
+ Assert.Equal(TracingMode.BlackAndWhite, reloaded.Presets.Single(p => p.Id == "trace-line-art").Trace.Mode);
+ }
+
[Fact]
public void Catalog_migration_ignores_extensions_checked_on_mixed_profiles()
{
diff --cc tests/Filee.Engines.Tests/TracingTests.cs
index dcd3f8e8,00000000..831e64f0
mode 100644,000000..100644
--- a/tests/Filee.Engines.Tests/TracingTests.cs
+++ b/tests/Filee.Engines.Tests/TracingTests.cs
@@@ -1,614 -1,0 +1,621 @@@
+// Raster → SVG tracing and SVG → DXF / DWG. Pictures are drawn with SkiaSharp in the tests; the traced SVG is rendered
+// back with Svg.Skia and compared with the input pixel by pixel, and DXF output is read back with ACadSharp.
+
+using System.Diagnostics;
+using System.Globalization;
+using System.Xml.Linq;
+using ACadSharp;
+using ACadSharp.Entities;
+using ACadSharp.IO;
+using ACadSharp.Types.Units;
+using Filee.Core.Conversion;
+using Filee.Core.Formats;
+using Filee.Core.Presets;
+using Filee.Engines.Vector;
+using Filee.Engines.Vector.Tracing;
+using ImageMagick;
+using SkiaSharp;
+
+namespace Filee.Engines.Tests;
+
+public class TracingTests(EngineFixture fx) : IClassFixture<EngineFixture>
+{
+ private static readonly XNamespace Svg = "http://www.w3.org/2000/svg";
+
+ private async Task<string> ConvertAsync(string input, Preset preset)
+ {
+ var job = await fx.ConvertAsync([input], preset);
+ var errors = string.Join("; ", job.Files.Where(f => f.State == FileState.Failed).Select(f => $"{f.ErrorKey} {f.ErrorDetail}"));
+ Assert.True(job.State == JobState.Completed, $"{job.State}: {errors}");
+ return job.Outputs.Single();
+ }
+
+ private static Preset LineArt(int detail = 50) =>
+ new() { Name = "Line art", TargetFormat = "svg", Trace = { Mode = TracingMode.BlackAndWhite, Detail = detail } };
+
+ private static Preset Colors(int colors, int detail = 50) =>
+ new() { Name = "Trace", TargetFormat = "svg", Trace = { Mode = TracingMode.Color, Colors = colors, Detail = detail } };
+
+ /// <summary>Draws a picture with SkiaSharp and saves it as PNG (or, through ImageMagick, another format).</summary>
+ private static string Draw(string folder, string name, int width, int height, SKColor background, Action<SKCanvas> draw)
+ {
+ using var bitmap = new SKBitmap(new SKImageInfo(width, height, SKColorType.Rgba8888, SKAlphaType.Premul));
+ using (var canvas = new SKCanvas(bitmap))
+ {
+ canvas.Clear(background);
+ draw(canvas);
+ }
+ using var data = bitmap.Encode(SKEncodedImageFormat.Png, 100);
+ var png = Path.Combine(folder, Path.ChangeExtension(name, ".png"));
+ File.WriteAllBytes(png, data.ToArray());
+ if (Path.GetExtension(name) is ".png")
+ return png;
+ var path = Path.Combine(folder, name);
+ using (var image = new MagickImage(png))
+ image.Write(path);
+ File.Delete(png);
+ return path;
+ }
+
+ private static SKPaint Fill(SKColor color, bool antialias = true) => new() { Color = color, IsAntialias = antialias, Style = SKPaintStyle.Fill };
+
+ /// <summary>Line art: a disc, a rectangle, a ring (with a hole), a thin bar and a slanted bar.</summary>
+ private static void DrawLineArt(SKCanvas canvas)
+ {
+ using var black = Fill(SKColors.Black);
+ canvas.DrawCircle(80, 80, 55, black);
+ canvas.DrawRect(170, 30, 120, 90, black);
+ canvas.DrawCircle(90, 220, 60, black);
+ using (var white = Fill(SKColors.White))
+ canvas.DrawCircle(90, 220, 30, white);
+ canvas.DrawRect(180, 170, 180, 3, black);
+ canvas.Save();
+ canvas.RotateDegrees(-25, 270, 240);
+ canvas.DrawRect(200, 230, 140, 14, black);
+ canvas.Restore();
+ }
+
+ /// <summary>RGBA pixels of a picture file drawn over <paramref name="background"/>.</summary>
+ private static byte[] Pixels(string path, int width, int height, SKColor background)
+ {
+ using var source = SKBitmap.Decode(path) ?? SKBitmap.Decode(new MagickImage(path).ToByteArray(MagickFormat.Png));
+ Assert.NotNull(source);
+ return Render(width, height, background, canvas => canvas.DrawBitmap(source, new SKRect(0, 0, width, height)));
+ }
+
+ /// <summary>RGBA pixels of an SVG rendered at <paramref name="width"/> × <paramref name="height"/>.</summary>
+ private static byte[] RenderSvg(string path, int width, int height, SKColor background)
+ {
+ using var drawing = SvgRenderer.Load(path);
+ return Render(width, height, background, canvas =>
+ {
+ canvas.Scale(width / drawing.Bounds.Width, height / drawing.Bounds.Height);
+ canvas.Translate(-drawing.Bounds.Left, -drawing.Bounds.Top);
+ canvas.DrawPicture(drawing.Picture);
+ });
+ }
+
+ private static byte[] Render(int width, int height, SKColor background, Action<SKCanvas> draw)
+ {
+ using var bitmap = new SKBitmap(new SKImageInfo(width, height, SKColorType.Rgba8888, SKAlphaType.Premul));
+ using (var canvas = new SKCanvas(bitmap))
+ {
+ canvas.Clear(background);
+ draw(canvas);
+ }
+ return bitmap.GetPixelSpan().ToArray();
+ }
+
+ /// <summary>Share of pixels whose colour differs by more than <paramref name="tolerance"/> in some channel.</summary>
+ private static double Difference(byte[] a, byte[] b, int tolerance = 64)
+ {
+ Assert.Equal(a.Length, b.Length);
+ var different = 0;
+ for (var i = 0; i < a.Length; i += 4)
+ {
+ if (Math.Abs(a[i] - b[i]) > tolerance || Math.Abs(a[i + 1] - b[i + 1]) > tolerance
+ || Math.Abs(a[i + 2] - b[i + 2]) > tolerance || Math.Abs(a[i + 3] - b[i + 3]) > tolerance)
+ different++;
+ }
+ return different / (a.Length / 4.0);
+ }
+
+ private static XElement[] PathsOf(string svg) => XDocument.Load(svg).Descendants(Svg + "path").ToArray();
+
+ private static int SubpathsOf(XElement path) => path.Attribute("d")!.Value.Count(c => c == 'M');
+
+ // ───────────────────────── Black and white ─────────────────────────
+
+ [Fact]
+ public async Task Line_art_becomes_one_black_path_that_looks_like_the_picture()
+ {
+ var dir = fx.NewFolder();
+ var png = Draw(dir, "logo.png", 400, 300, SKColors.White, DrawLineArt);
+
+ var svg = await ConvertAsync(png, LineArt());
+
+ var root = XDocument.Load(svg).Root!;
+ Assert.Equal(("400", "300", "0 0 400 300"), (root.Attribute("width")?.Value, root.Attribute("height")?.Value, root.Attribute("viewBox")?.Value));
+ var path = Assert.Single(PathsOf(svg));
+ Assert.Equal("#000000", path.Attribute("fill")?.Value);
+ // Disc, rectangle, ring outside + inside, thin bar, slanted bar.
+ Assert.Equal(6, SubpathsOf(path));
+ var data = path.Attribute("d")!.Value;
+ Assert.Contains('C', data); // curves for the round shapes
+ Assert.Contains('L', data); // straight lines for the rectangle
+
+ var difference = Difference(Pixels(png, 400, 300, SKColors.White), RenderSvg(svg, 400, 300, SKColors.White));
+ Assert.True(difference < 0.01, $"{difference:P2} of the pixels differ");
+ }
+
+ [Fact]
+ public async Task Line_art_drops_specks_unless_the_detail_is_highest()
+ {
+ var dir = fx.NewFolder();
+ var specks = 0;
+ var png = Draw(dir, "scan.png", 300, 200, SKColors.White, canvas =>
+ {
+ using var black = Fill(SKColors.Black, antialias: false);
+ canvas.DrawRect(50, 50, 200, 100, black);
+ var random = new Random(7);
+ for (var i = 0; i < 40; i++)
+ {
+ var x = random.Next(0, 300);
+ var y = random.Next(0, 200);
+ if (x is >= 45 and <= 255 && y is >= 45 and <= 155)
+ continue;
+ canvas.DrawRect(x, y, 2, 1, black); // dust: 2 pixels each
+ specks++;
+ }
+ });
+
+ var cleaned = PathsOf(await ConvertAsync(png, LineArt()));
+ var everything = PathsOf(await ConvertAsync(png, LineArt(detail: 100).Also(p => p.Output.FileNamePattern = "{name}_all")));
+
+ Assert.Equal(1, SubpathsOf(Assert.Single(cleaned)));
+ Assert.InRange(SubpathsOf(Assert.Single(everything)), 1 + specks * 0.8, 1 + specks);
+ }
+
+ [Fact]
+ public async Task Line_art_on_a_transparent_background_traces_the_opaque_shapes()
+ {
+ var dir = fx.NewFolder();
+ // A white logo on nothing: over white paper it would vanish, so the opaque pixels are the ink.
+ var png = Draw(dir, "white-logo.png", 200, 200, SKColors.Transparent, canvas =>
+ {
+ using var white = Fill(SKColors.White);
+ canvas.DrawCircle(100, 100, 70, white);
+ });
+
+ var path = Assert.Single(PathsOf(await ConvertAsync(png, LineArt())));
+ Assert.Equal(1, SubpathsOf(path));
+ }
+
+ // ───────────────────────── Colour ─────────────────────────
+
+ private static void DrawIllustration(SKCanvas canvas)
+ {
+ using var red = Fill(new SKColor(0xE5, 0x39, 0x35));
+ using var blue = Fill(new SKColor(0x1E, 0x63, 0xC8));
+ using var green = Fill(new SKColor(0x2E, 0x9D, 0x4F));
+ using var yellow = Fill(new SKColor(0xF9, 0xC8, 0x2B));
+ canvas.DrawCircle(110, 110, 80, red);
+ canvas.DrawRect(150, 120, 120, 110, blue);
+ using (var triangle = new SKPath())
+ {
+ triangle.MoveTo(40, 280);
+ triangle.LineTo(120, 170);
+ triangle.LineTo(200, 280);
+ triangle.Close();
+ canvas.DrawPath(triangle, green);
+ }
+ canvas.DrawCircle(210, 175, 25, yellow);
+ }
+
+ [Fact]
+ public async Task Colour_tracing_stacks_one_path_per_colour_without_gaps()
+ {
+ var dir = fx.NewFolder();
+ var png = Draw(dir, "illustration.png", 300, 300, SKColors.White, DrawIllustration);
+
+ var svg = await ConvertAsync(png, Colors(8));
+
+ var paths = PathsOf(svg);
+ // White, red, blue, green, yellow: the anti-aliased edges don't get colours of their own.
+ Assert.Equal(5, paths.Length);
+ Assert.Equal("#ffffff", paths[0].Attribute("fill")?.Value); // the background at the bottom
+ Assert.Equal(1, SubpathsOf(paths[0]));
+
+ var expected = Pixels(png, 300, 300, SKColors.White);
+ Assert.True(Difference(expected, RenderSvg(svg, 300, 300, SKColors.White)) < 0.02);
+ // Drawn over magenta, no magenta shows: lower shapes run under the upper ones.
+ var overMagenta = RenderSvg(svg, 300, 300, SKColors.Magenta);
+ Assert.True(Difference(expected, overMagenta) < 0.02);
+ var magenta = 0;
+ for (var i = 0; i < overMagenta.Length; i += 4)
+ if (overMagenta[i] > 200 && overMagenta[i + 1] < 60 && overMagenta[i + 2] > 200)
+ magenta++;
+ Assert.True(magenta < 30, $"{magenta} magenta pixels");
+ }
+
+ [Fact]
+ public async Task Colour_tracing_reduces_to_the_colour_count()
+ {
+ var dir = fx.NewFolder();
+ var png = Draw(dir, "gradient.png", 256, 64, SKColors.White, canvas =>
+ {
+ using var shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(256, 0), [SKColors.Black, SKColors.White], SKShaderTileMode.Clamp);
+ using var paint = new SKPaint { Shader = shader };
+ canvas.DrawRect(0, 0, 256, 64, paint);
+ });
+
+ var paths = PathsOf(await ConvertAsync(png, Colors(4)));
+
+ Assert.Equal(4, paths.Length);
+ Assert.Equal(4, paths.Select(p => p.Attribute("fill")!.Value).Distinct().Count());
+ }
+
+ [Fact]
+ public async Task Transparent_areas_stay_transparent_in_colour_tracing()
+ {
+ var dir = fx.NewFolder();
+ var png = Draw(dir, "sticker.png", 200, 200, SKColors.Transparent, canvas =>
+ {
+ using var red = Fill(SKColors.Red);
+ canvas.DrawCircle(100, 100, 60, red);
+ });
+
+ var svg = await ConvertAsync(png, Colors(8));
+
+ var path = Assert.Single(PathsOf(svg));
+ Assert.Equal("#ff0000", path.Attribute("fill")?.Value);
+ var rendered = RenderSvg(svg, 200, 200, SKColors.Transparent);
+ Assert.Equal(0, rendered[(10 * 200 + 10) * 4 + 3]); // corner
+ Assert.Equal(255, rendered[(100 * 200 + 100) * 4 + 3]); // centre
+ }
+
+ // ───────────────────────── Inputs and size ─────────────────────────
+
+ [Theory]
+ [InlineData("jpg")]
+ [InlineData("bmp")]
+ [InlineData("gif")]
+ [InlineData("webp")]
+ [InlineData("tiff")]
+ public async Task Common_image_formats_are_traced(string format)
+ {
+ var dir = fx.NewFolder();
+ var input = Draw(dir, "art." + format, 300, 300, SKColors.White, DrawIllustration);
+
+ var svg = await ConvertAsync(input, Colors(8));
+
+ Assert.Equal(".svg", Path.GetExtension(svg));
+ Assert.InRange(PathsOf(svg).Length, 4, 8);
+ var difference = Difference(Pixels(input, 300, 300, SKColors.White), RenderSvg(svg, 300, 300, SKColors.White));
+ Assert.True(difference < 0.03, $"{difference:P2} of the pixels differ");
+ }
+
+ [Fact]
+ public async Task Only_the_first_page_of_a_tiff_is_traced()
+ {
+ var dir = fx.NewFolder();
+ var tiff = EngineFixture.MakeMultiPageTiff(dir, 3);
+
+ var job = await fx.ConvertAsync([tiff], Colors(4));
+
+ Assert.Equal(JobState.Completed, job.State);
+ var path = Assert.Single(PathsOf(Assert.Single(job.Outputs)));
+ Assert.Equal("#ff7f50", path.Attribute("fill")?.Value); // coral, the first page
+ }
+
+ [Fact]
+ public async Task Huge_pictures_are_reduced_for_tracing_and_keep_their_size()
+ {
+ var dir = fx.NewFolder();
+ var png = Draw(dir, "banner.png", 5000, 400, SKColors.White, canvas =>
+ {
+ using var black = Fill(SKColors.Black);
+ for (var x = 100; x < 4900; x += 600)
+ canvas.DrawCircle(x, 200, 150, black);
+ });
+
+ var svg = await ConvertAsync(png, LineArt());
+
+ var root = XDocument.Load(svg).Root!;
+ Assert.Equal(("5000", "400"), (root.Attribute("width")?.Value, root.Attribute("height")?.Value));
+ Assert.Contains(XDocument.Load(svg).DescendantNodes().OfType<XComment>(), c => c.Value.Contains("reduced to 4096 x 328", StringComparison.Ordinal));
+ Assert.Equal(8, SubpathsOf(Assert.Single(PathsOf(svg))));
+ var difference = Difference(Pixels(png, 1250, 100, SKColors.White), RenderSvg(svg, 1250, 100, SKColors.White));
+ Assert.True(difference < 0.02, $"{difference:P2} of the pixels differ");
+ }
+
+ [Theory]
+ [InlineData(5000, 400, 4096, 328)]
+ [InlineData(4000, 4000, 2449, 2449)]
+ [InlineData(2000, 2000, 2000, 2000)]
+ public void Traced_size_is_capped(int width, int height, int tracedWidth, int tracedHeight) =>
+ Assert.Equal((tracedWidth, tracedHeight), RasterTracing.TracedSize(width, height));
+
+ [Fact]
+ public async Task A_2000_pixel_illustration_traces_in_a_few_seconds()
+ {
+ var dir = fx.NewFolder();
+ var random = new Random(3);
+ SKColor[] palette = [new(0xE5, 0x39, 0x35), new(0x1E, 0x63, 0xC8), new(0x2E, 0x9D, 0x4F), new(0xF9, 0xC8, 0x2B),
+ new(0x6A, 0x1B, 0x9A), new(0x00, 0x83, 0x8F), new(0x37, 0x47, 0x4F), new(0xFF, 0x8F, 0x00)];
+ var png = Draw(dir, "poster.png", 2000, 2000, new SKColor(0xFA, 0xF7, 0xF0), canvas =>
+ {
+ for (var i = 0; i < 150; i++)
+ {
+ using var paint = Fill(palette[random.Next(palette.Length)]);
+ var x = random.Next(0, 2000);
+ var y = random.Next(0, 2000);
+ if (i % 3 == 0)
+ canvas.DrawRect(x, y, random.Next(40, 300), random.Next(40, 300), paint);
+ else
+ canvas.DrawCircle(x, y, random.Next(10, 160), paint);
+ }
+ using var text = Fill(SKColors.Black);
+ using var font = new SKFont(SKTypeface.Default, 120);
+ canvas.DrawText("Filee 2000", 200, 1000, font, text);
+ });
+
+ foreach (var preset in new[] { Colors(16), LineArt() })
+ {
+ preset.Output.FileNamePattern = "{name}_" + preset.Trace.Mode;
+ var watch = Stopwatch.StartNew();
+ var svg = await ConvertAsync(png, preset);
+ watch.Stop();
+ TestContext.Current.TestOutputHelper?.WriteLine(string.Create(CultureInfo.InvariantCulture,
+ $"{preset.Trace.Mode}: {watch.Elapsed.TotalSeconds:0.00} s, {new FileInfo(svg).Length / 1024} KB, {PathsOf(svg).Sum(SubpathsOf)} outlines"));
+ Assert.True(watch.Elapsed < TimeSpan.FromSeconds(30), $"{preset.Trace.Mode} took {watch.Elapsed}");
+ if (preset.Trace.Mode == TracingMode.Color)
+ {
+ var difference = Difference(Pixels(png, 500, 500, SKColors.White), RenderSvg(svg, 500, 500, SKColors.White));
+ Assert.True(difference < 0.03, $"{difference:P2} of the pixels differ");
+ }
+ }
+ }
+
+ // ───────────────────────── Routes ─────────────────────────
+
+ [Theory]
+ [InlineData("png")]
+ [InlineData("jpg")]
+ [InlineData("bmp")]
+ [InlineData("gif")]
+ [InlineData("webp")]
+ [InlineData("tiff")]
+ [InlineData("heic")]
+ public void Raster_images_reach_svg_by_tracing_and_cad_through_svg(string from)
+ {
+ var planner = fx.Catalog.CreatePlanner();
+
+ Assert.Equal("vector", Assert.Single(planner.Plan(from, "svg")!.Steps).Converter.Id);
+ Assert.Equal(["svg", "dxf"], planner.Plan(from, "dxf")!.Steps.Select(s => s.To));
+ Assert.Equal(["svg", "dxf", "dwg"], planner.Plan(from, "dwg")!.Steps.Select(s => s.To));
+ // Everything else keeps the image engines' routes.
+ Assert.Equal("pdfsharp", Assert.Single(planner.Plan(from, "pdf")!.Steps).Converter.Id);
+ Assert.DoesNotContain(planner.Plan(from, "eps")?.Steps ?? [], s => s.To == "svg");
+ }
+
+ [Fact]
+ public void Icns_is_traced_through_png()
+ {
+ var route = fx.Catalog.CreatePlanner().Plan("icns", "svg");
+
+ Assert.NotNull(route);
+ Assert.Equal(["png", "svg"], route.Steps.Select(s => s.To));
+ }
+
+ [Theory]
+ [InlineData("pdf")]
+ [InlineData("eps")]
+ [InlineData("ps")]
+ [InlineData("ai")]
+ [InlineData("emf")]
+ [InlineData("wmf")]
+ [InlineData("cdr")]
+ [InlineData("docx")]
+ [InlineData("mp4")]
+ public void Files_that_are_not_raster_images_are_never_traced(string from)
+ {
- // With every optional engine as if installed: a vector route (LibreOffice for EMF, CDR) is fine, tracing a
- // rendering is not, so PDF and EPS have no SVG target at all.
- var planner = fx.Catalog.CreatePlanner(fx.Converters.Select(c => c.Id).ToArray());
- foreach (var to in new[] { "svg", "svgz", "dxf", "dwg" })
- Assert.DoesNotContain(planner.Plan(from, to)?.Steps ?? [], IsTracing);
- if (from is "pdf" or "eps" or "ps" or "ai")
- Assert.Null(planner.Plan(from, "svg"));
++ // With every optional engine as if installed, and with the built-in ones only: a vector route (LibreOffice for
++ // PDF, EMF, CDR) is fine, tracing a rendering is not.
++ var everyEngine = fx.Catalog.CreatePlanner(fx.Converters.Select(c => c.Id).ToArray());
++ var builtIn = new RoutePlanner(fx.Converters.Where(c => c.Id is not ("libreoffice" or "ghostscript" or "pandoc" or "calibre" or "ffmpeg")));
++ foreach (var planner in new[] { everyEngine, builtIn })
++ {
++ foreach (var to in new[] { "svg", "svgz", "dxf", "dwg" })
++ Assert.DoesNotContain(planner.Plan(from, to)?.Steps ?? [], IsTracing);
++ }
++ Assert.Null(builtIn.Plan(from, "svg"));
+ }
+
+ [Fact]
+ public void Tracing_is_never_a_step_towards_a_format_that_has_another_route()
+ {
+ // Every engine as if installed, so optional engines' edges are part of the check.
+ var everyEngine = fx.Converters.Select(c => c.Id).ToArray();
+ var withTracing = fx.Catalog.CreatePlanner(everyEngine);
+ var without = new ConverterCatalog(fx.Converters.Select(c => c is VectorConverter ? new WithoutTracing(c) : c))
+ {
+ Priority = fx.Catalog.Priority,
+ }.CreatePlanner(everyEngine);
+
+ var formats = FormatRegistry.Known.Select(f => f.Id).ToList();
+ var checkedRoutes = 0;
+ foreach (var from in formats)
+ {
+ foreach (var to in formats.Where(t => t != from))
+ {
+ var route = withTracing.Plan(from, to);
+ // Only raster images are ever traced.
+ if (FormatRegistry.FindById(from)?.Category != FormatCategory.Image)
+ Assert.False(route?.Steps.Any(IsTracing) ?? false, $"{from} → {to} traces a rendering");
+ var other = without.Plan(from, to);
+ if (other is null)
+ continue;
+ Assert.NotNull(route);
+ Assert.False(route.Steps.Any(IsTracing), $"{from} → {to} traces: {string.Join(" → ", route.Steps.Select(s => s.To))}");
+ Assert.Equal(other.Cost, route.Cost);
+ checkedRoutes++;
+ }
+ }
+ Assert.True(checkedRoutes > 1000);
+ }
+
+ private static bool IsTracing(RouteStep step) => step.Converter is VectorConverter && step.To == "svg" && step.From is not "svgz";
+
+ /// <summary>The vector engine without its tracing edges.</summary>
+ private sealed class WithoutTracing(IConverter inner) : IConverter
+ {
+ public string Id => inner.Id;
+ public string DisplayName => inner.DisplayName;
+ public int MaxParallelism => inner.MaxParallelism;
+ public IReadOnlyList<ConversionEdge> Edges { get; } = inner.Edges.Where(e => !e.ImageSourcesOnly).ToList();
+ public EngineStatus GetStatus() => inner.GetStatus();
+ public Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProgress<double>? progress, CancellationToken cancellationToken) =>
+ inner.ConvertAsync(step, progress, cancellationToken);
+ }
+
+ // ───────────────────────── SVG → DXF / DWG ─────────────────────────
+
+ private const string Drawing = """
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="96" viewBox="0 0 96 96">
+ <defs><rect id="tile" width="10" height="10"/></defs>
+ <rect x="10" y="10" width="30" height="20" fill="#ff0000"/>
+ <circle cx="60" cy="20" r="9.6" fill="none" stroke="#0000ff"/>
+ <ellipse cx="20" cy="60" rx="12" ry="6" transform="rotate(30 20 60)" fill="#00ff00"/>
+ <line x1="50" y1="50" x2="90" y2="50" stroke="black"/>
+ <polyline points="50,60 60,70 70,60 80,70" fill="none" stroke="black"/>
+ <polygon points="50,80 60,90 40,90"/>
+ <path d="M 10 80 C 10 70, 30 70, 30 80 A 5 5 0 0 1 20 85 Z" fill="none" stroke="black"/>
+ <g transform="translate(70 75) scale(2)"><use xlink:href="#tile"/></g>
+ </svg>
+ """;
+
+ [Fact]
+ public async Task Svg_becomes_dxf_in_millimetres_with_y_up()
+ {
+ var dir = fx.NewFolder();
+ var svg = Path.Combine(dir, "parts.svg");
+ await File.WriteAllTextAsync(svg, Drawing, TestContext.Current.CancellationToken);
+
+ var dxf = await ConvertAsync(svg, new Preset { TargetFormat = "dxf" });
+
+ var document = DxfReader.Read(dxf);
+ Assert.Equal(UnitsType.Millimeters, document.Header.InsUnits);
+ const double mm = 25.4 / 96; // 96 px = 1 inch, so the drawing is 25.4 mm square
+ var entities = document.Entities.ToList();
+
+ // The rectangle: closed, its top-left corner (10, 10) at y = 96 - 10 from the bottom.
+ var rectangle = entities.OfType<LwPolyline>().Single(p => p.Color.R == 255 && p.Color.G == 0);
+ Assert.True(rectangle.IsClosed);
+ Assert.Equal(4, rectangle.Vertices.Count);
+ Assert.Contains(rectangle.Vertices, v => Near(v.Location.X, 10 * mm) && Near(v.Location.Y, 86 * mm));
+ Assert.Contains(rectangle.Vertices, v => Near(v.Location.X, 40 * mm) && Near(v.Location.Y, 66 * mm));
+
+ var circle = Assert.Single(entities.OfType<Circle>());
+ Assert.True(Near(circle.Center.X, 60 * mm) && Near(circle.Center.Y, 76 * mm) && Near(circle.Radius, 9.6 * mm), $"{circle.Center} r {circle.Radius}");
+ Assert.Equal((0, 0, 255), (circle.Color.R, circle.Color.G, circle.Color.B));
+
+ var ellipse = Assert.Single(entities.OfType<Ellipse>());
+ Assert.True(Near(ellipse.Center.X, 20 * mm) && Near(ellipse.Center.Y, 36 * mm));
+ Assert.True(Near(ellipse.RadiusRatio, 0.5));
+ Assert.True(Near(ellipse.MajorAxisEndPoint.X, 12 * mm * Math.Cos(Math.PI / 6)) && Near(ellipse.MajorAxisEndPoint.Y, -12 * mm * Math.Sin(Math.PI / 6)),
+ ellipse.MajorAxisEndPoint.ToString());
+
+ var line = Assert.Single(entities.OfType<Line>());
+ Assert.True(Near(line.StartPoint.X, 50 * mm) && Near(line.StartPoint.Y, 46 * mm) && Near(line.EndPoint.X, 90 * mm));
+
+ Assert.Contains(entities.OfType<LwPolyline>(), p => !p.IsClosed && p.Vertices.Count == 4); // the polyline
+ Assert.Contains(entities.OfType<LwPolyline>(), p => p.IsClosed && p.Vertices.Count == 3); // the polygon
+ // The path's curve and arc are divided into short straight pieces.
+ var curved = entities.OfType<LwPolyline>().Single(p => p.IsClosed && p.Vertices.Count > 20);
+ // The arc is too short for its radius, so SVG enlarges it (to 5.59) and it bulges a little past x = 30.
+ Assert.All(curved.Vertices, v => Assert.InRange(v.Location.X, 9.99 * mm, 30.7 * mm));
+ Assert.Contains(curved.Vertices, v => v.Location.X > 30.5 * mm);
+ Assert.Contains(curved.Vertices, v => Near(v.Location.Y, (96 - 85) * mm, 0.05));
+
+ // <use> inside a translated and scaled group: (70, 75) to (90, 95).
+ var tile = entities.OfType<LwPolyline>().Single(p => p.IsClosed && p.Vertices.Count == 4 && p.Color.R == 0);
+ Assert.Contains(tile.Vertices, v => Near(v.Location.X, 70 * mm) && Near(v.Location.Y, 21 * mm));
+ Assert.Contains(tile.Vertices, v => Near(v.Location.X, 90 * mm) && Near(v.Location.Y, 1 * mm));
+ }
+
+ private static bool Near(double a, double b, double tolerance = 1e-3) => Math.Abs(a - b) < tolerance;
+
+ [Fact]
+ public async Task Svg_text_becomes_outlines_in_dxf()
+ {
++ // Text needs a font with outlines; a CI machine without fonts has none to draw with.
++ using (var font = new SKFont(SKFontManager.Default.MatchFamily("sans-serif") ?? SKTypeface.Default, 40))
++ using (var glyph = font.GetGlyphPath(font.GetGlyphs("H")[0]))
++ Assert.SkipWhen(glyph is null || glyph.IsEmpty, "no font with outlines on this machine");
+ var dir = fx.NewFolder();
+ var svg = Path.Combine(dir, "label.svg");
+ await File.WriteAllTextAsync(svg, """
+ <svg xmlns="http://www.w3.org/2000/svg" width="200" height="60"><text x="10" y="45" font-size="40" font-family="sans-serif">Hi</text></svg>
+ """, TestContext.Current.CancellationToken);
+
+ var document = DxfReader.Read(await ConvertAsync(svg, new Preset { TargetFormat = "dxf" }));
+
+ var outlines = document.Entities.OfType<LwPolyline>().ToList();
+ Assert.True(outlines.Count >= 3, $"{outlines.Count} outlines"); // H, the stem and dot of i
+ Assert.All(outlines, o => Assert.True(o.IsClosed));
+ }
+
+ [Fact]
+ public async Task Svg_reaches_dwg_through_dxf()
+ {
+ var dir = fx.NewFolder();
+ var svg = Path.Combine(dir, "parts.svg");
+ await File.WriteAllTextAsync(svg, Drawing, TestContext.Current.CancellationToken);
+
+ Assert.Equal("vector,cad", string.Join(',', fx.Catalog.CreatePlanner().Plan("svg", "dwg")!.Steps.Select(s => s.Converter.Id)));
+ var dwg = await ConvertAsync(svg, new Preset { TargetFormat = "dwg" });
+
+ var document = DwgReader.Read(dwg);
+ Assert.Single(document.Entities.OfType<Circle>());
+ Assert.Single(document.Entities.OfType<Ellipse>());
+ Assert.Equal(8, document.Entities.Count()); // every shape of the drawing
+ }
+
+ [Fact]
+ public async Task Traced_line_art_becomes_closed_dxf_outlines()
+ {
+ var dir = fx.NewFolder();
+ var png = Draw(dir, "logo.png", 400, 300, SKColors.White, DrawLineArt);
+
+ var dxf = await ConvertAsync(png, LineArt().Also(p => p.TargetFormat = "dxf"));
+
+ var outlines = DxfReader.Read(dxf).Entities.OfType<LwPolyline>().ToList();
+ Assert.Equal(6, outlines.Count);
+ Assert.All(outlines, o => Assert.True(o.IsClosed));
+ // 400 px wide at 96 px per inch.
+ Assert.True(outlines.Max(o => o.Vertices.Max(v => v.Location.X)) < 400 * 25.4 / 96);
+ }
+
+ [Fact]
+ public async Task Svg_with_nothing_to_outline_fails_with_a_message()
+ {
+ var dir = fx.NewFolder();
+ var svg = Path.Combine(dir, "empty.svg");
+ await File.WriteAllTextAsync(svg, """<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><g/></svg>""", TestContext.Current.CancellationToken);
+
+ var job = await fx.ConvertAsync([svg], new Preset { TargetFormat = "dxf" });
+
+ Assert.Equal(JobState.Failed, job.State);
+ }
+}
+
+internal static class PresetTestExtensions
+{
+ /// <summary>Changes a preset in an expression.</summary>
+ public static Preset Also(this Preset preset, Action<Preset> change)
+ {
+ change(preset);
+ return preset;
+ }
+}