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

+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: