feat(app): add image input support and bump to 1.5.0

Allow PNG/JPG/TIFF/BMP/GIF/WebP alongside PDF for preview and DXF conversion.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Michael-A-SloanandCursor committed 2026-09-03 17:05:17 -04:00
1 parent 19696937df
commit 2c9829ef8c
9 files changed
+88 -28

No files matched your search

+7 -7
View File
@@ -1,15 +1,15 @@
# PDF to DXF Converter
# PDF / Image to DXF Converter
Windows desktop app that converts PDF drawings to **DXF** for BricsCAD (and other CAD software), with a live page preview. Optionally saves **DWG** through your installed BricsCAD.
Windows desktop app that converts PDF and image drawings to **DXF** for BricsCAD (and other CAD software), with a live preview. Optionally saves **DWG** through your installed BricsCAD.
**License:** [MIT](LICENSE)
## Features
- PDF page preview with previous/next navigation
- PDF and image preview (`PNG`, `JPG`, `TIFF`, `BMP`, `GIF`, `WebP`)
- Conversion modes: **auto**, **vector**, **vectorize**, **raster**
- True vector PDFs → editable lines/polylines/text in DXF
- Flattened / image-only drawing PDFs → traced to editable polylines (`vectorize`)
- Image files and flattened PDFs → traced to editable polylines (`vectorize`)
- Optional raster underlay mode for scans you want as images
- Optional DWG export via BricsCAD `SAVEAS`
@@ -51,7 +51,7 @@ Optional only: BricsCAD for DWG save.
## Usage
1. Click **Open PDF…** and pick a file
1. Click **Open PDF or Image…** and pick a supported file
2. Preview pages with ◀ / ▶
3. Choose mode (`auto` recommended), pages, and scale (1.0 = PDF size; use your own multiplier)
4. Click **Convert & Save…** — review each page (vector / image / vectorize / skip), then pick the DXF path
@@ -61,9 +61,9 @@ Optional only: BricsCAD for DWG save.
| Mode | Best for | Result |
|------|----------|--------|
| `auto` | Mixed PDFs | Native vectors when present; traces image-only drawing pages |
| `auto` | PDFs and images | Native vectors when present; traces image-only inputs |
| `vector` | CAD-exported PDFs | Editable geometry and text (traces if the page is only a bitmap) |
| `vectorize` | Flattened / printed drawing PDFs | Raster-to-vector polylines (set **Trace detail** to high/maximum) |
| `vectorize` | Images and flattened drawing PDFs | Raster-to-vector polylines (set **Trace detail** to high/maximum) |
| `raster` | Photos / underlays | Full-page image in the DXF |
### BricsCAD DWG
+1 -1
View File
@@ -1,3 +1,3 @@
"""PDF to DXF converter application package."""
__version__ = "1.4.1"
__version__ = "1.5.0"
+5 -4
View File
@@ -13,6 +13,7 @@ import ezdxf
import fitz
from ezdxf import units
from app.input_document import open_input_document
from app.raster_vectorize import vectorize_page
@@ -142,13 +143,13 @@ def classify_page(
def classify_pdf_pages(
pdf_path: str | Path,
input_path: str | Path,
pages: list[int] | None = None,
*,
vector_threshold: int = 20,
) -> list[PageClassification]:
"""Classify selected pages of a PDF for the pre-convert review dialog."""
pdf = fitz.open(str(pdf_path))
"""Classify selected pages of a PDF or image for pre-convert review."""
pdf = open_input_document(input_path)
try:
indices = _page_indices(pdf, pages)
return [
@@ -1134,7 +1135,7 @@ def convert_pdf_to_dxf(
pdf_path = Path(pdf_path)
output_path = Path(output_path)
pdf = fitz.open(str(pdf_path))
pdf = open_input_document(pdf_path)
try:
indices = _page_indices(pdf, options.pages)
if not indices:
+45
View File
@@ -0,0 +1,45 @@
"""Open supported PDF and image inputs as PDF documents."""
from __future__ import annotations
from pathlib import Path
import fitz
PDF_EXTENSIONS = {".pdf"}
IMAGE_EXTENSIONS = {
".bmp",
".gif",
".jpeg",
".jpg",
".png",
".tif",
".tiff",
".webp",
}
SUPPORTED_EXTENSIONS = PDF_EXTENSIONS | IMAGE_EXTENSIONS
def is_image_input(path: str | Path) -> bool:
"""Return whether the selected input is a supported image."""
return Path(path).suffix.lower() in IMAGE_EXTENSIONS
def open_input_document(path: str | Path) -> fitz.Document:
"""Open a PDF directly or wrap an image in an in-memory PDF."""
input_path = Path(path)
extension = input_path.suffix.lower()
if extension not in SUPPORTED_EXTENSIONS:
supported = ", ".join(sorted(SUPPORTED_EXTENSIONS))
raise ValueError(f"Unsupported input type. Supported: {supported}")
document = fitz.open(str(input_path))
if extension in PDF_EXTENSIONS:
return document
try:
pdf_bytes = document.convert_to_pdf()
finally:
document.close()
return fitz.open("pdf", pdf_bytes)
+4 -1
View File
@@ -7,9 +7,12 @@ from pathlib import Path
import fitz
from PIL import Image
from app.input_document import open_input_document
def open_document(path: str | Path) -> fitz.Document:
return fitz.open(str(path))
"""Open a supported PDF or image for preview."""
return open_input_document(path)
def page_count(doc: fitz.Document) -> int:
+20 -10
View File
@@ -1,4 +1,4 @@
"""Main CustomTkinter UI for PDF to DXF conversion."""
"""Main CustomTkinter UI for PDF/image to DXF conversion."""
from __future__ import annotations
@@ -16,6 +16,7 @@ from app.converter import (
convert_pdf_to_dxf,
parse_page_range,
)
from app.input_document import IMAGE_EXTENSIONS, is_image_input
from app.page_review import ask_page_modes
from app.pdf_preview import close_document, open_document, page_count, render_page
@@ -27,7 +28,7 @@ ctk.set_default_color_theme("blue")
class App(ctk.CTk):
def __init__(self) -> None:
super().__init__()
self.title(f"PDF to DXF Converter v{__version__}")
self.title(f"PDF / Image to DXF Converter v{__version__}")
self.geometry("1100x720")
self.minsize(800, 520)
@@ -66,19 +67,19 @@ class App(ctk.CTk):
ctk.CTkLabel(
scroll,
text="PDF → DXF",
text="PDF / Image → DXF",
font=ctk.CTkFont(size=22, weight="bold"),
).pack(padx=16, pady=(16, 4), anchor="w", fill="x")
self._add_wrap_label(
scroll,
"Preview & convert for BricsCAD",
"Preview and convert drawings for BricsCAD",
font=ctk.CTkFont(size=12),
text_color=("gray40", "gray70"),
pady=(0, 12),
)
ctk.CTkButton(scroll, text="Open PDF…", command=self._open_pdf).pack(
ctk.CTkButton(scroll, text="Open PDF or Image…", command=self._open_pdf).pack(
padx=16, pady=6, fill="x"
)
@@ -220,7 +221,7 @@ class App(ctk.CTk):
self.preview_label = ctk.CTkLabel(
self.preview_frame,
text="Open a PDF to see a preview",
text="Open a PDF or image to see a preview",
text_color=("gray40", "gray60"),
)
self.preview_label.grid(row=0, column=0, sticky="nsew")
@@ -307,8 +308,16 @@ class App(ctk.CTk):
if self._busy:
return
path = filedialog.askopenfilename(
title="Open PDF",
filetypes=[("PDF files", "*.pdf"), ("All files", "*.*")],
title="Open PDF or Image",
filetypes=[
(
"PDF and image files",
"*.pdf *.png *.jpg *.jpeg *.tif *.tiff *.bmp *.gif *.webp",
),
("PDF files", "*.pdf"),
("Image files", " ".join(f"*{ext}" for ext in sorted(IMAGE_EXTENSIONS))),
("All files", "*.*"),
],
)
if not path:
return
@@ -319,7 +328,8 @@ class App(ctk.CTk):
self._page_index = 0
self.file_label.configure(text=self._pdf_path.name)
self._refresh_preview()
self._set_status(f"Loaded {page_count(self._doc)} page(s)")
input_kind = "image" if is_image_input(path) else "PDF"
self._set_status(f"Loaded {input_kind}: {page_count(self._doc)} page(s)")
except Exception as exc:
messagebox.showerror("Open failed", str(exc))
self._set_status("Failed to open PDF")
@@ -373,7 +383,7 @@ class App(ctk.CTk):
if self._busy:
return
if self._doc is None or self._pdf_path is None:
messagebox.showinfo("No PDF", "Open a PDF file first.")
messagebox.showinfo("No input", "Open a PDF or image file first.")
return
try:
+1
View File
@@ -54,6 +54,7 @@ Write-Host "Building application (folder payload)..."
--hidden-import app.pdf_preview `
--hidden-import app.ocr_support `
--hidden-import app.page_review `
--hidden-import app.input_document `
main.py
$AppExe = Join-Path $AppDistDir "$AppDistName.exe"
+1 -1
View File
@@ -15,7 +15,7 @@ import zipfile
from pathlib import Path
# Keep in sync with app.__version__
APP_VERSION = "1.4.1"
APP_VERSION = "1.5.0"
APP_NAME = "PDF_to_DXF"
PAYLOAD_NAME = "app_payload.zip"
+4 -4
View File
@@ -1,5 +1,5 @@
PDF to DXF Converter — single EXE
=================================
PDF / Image to DXF Converter — single EXE
=========================================
How to install on another PC
----------------------------
@@ -14,9 +14,9 @@ re-installs automatically.
What works with nothing else installed
--------------------------------------
- Open PDF, preview pages
- Open and preview PDF or image files (PNG, JPG, TIFF, BMP, GIF, WebP)
- Convert to DXF (vector / vectorize / raster / auto)
- High-detail tracing of flattened drawing PDFs
- High-detail tracing of image files and flattened drawing PDFs
- OCR for outlined / non-selectable text (bundled language data)
Optional (not required)