|
|
|
|
@ -448,7 +448,12 @@ def _compile_pdflatex(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _render_png_with_magick(
|
|
|
|
|
run_dir: Path, pdf_path: Path, run_logger: RunLogger, section_title: str, png_name: str = "diagram.png"
|
|
|
|
|
run_dir: Path,
|
|
|
|
|
pdf_path: Path,
|
|
|
|
|
run_logger: RunLogger,
|
|
|
|
|
section_title: str,
|
|
|
|
|
png_name: str = "diagram.png",
|
|
|
|
|
size: str | None = None,
|
|
|
|
|
) -> Optional[Path]:
|
|
|
|
|
png_path = run_dir / png_name
|
|
|
|
|
|
|
|
|
|
@ -464,8 +469,23 @@ def _render_png_with_magick(
|
|
|
|
|
"remove",
|
|
|
|
|
"-alpha",
|
|
|
|
|
"off",
|
|
|
|
|
str(png_path),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# If size is specified, add center-fit resizing (e.g., "1200x630")
|
|
|
|
|
if size:
|
|
|
|
|
cmd.extend(
|
|
|
|
|
[
|
|
|
|
|
"-resize",
|
|
|
|
|
size,
|
|
|
|
|
"-gravity",
|
|
|
|
|
"center",
|
|
|
|
|
"-extent",
|
|
|
|
|
size,
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cmd.append(str(png_path))
|
|
|
|
|
|
|
|
|
|
code, out = _run_cmd(cmd, cwd=run_dir, timeout_s=5, py_logger=run_logger.py)
|
|
|
|
|
run_logger.section(section_title, out)
|
|
|
|
|
if code == 0 and png_path.exists():
|
|
|
|
|
@ -571,6 +591,19 @@ def _compile_phase(
|
|
|
|
|
if pdf_path
|
|
|
|
|
else None
|
|
|
|
|
)
|
|
|
|
|
# Render preview.png with OG image size (1200x630, center-fit)
|
|
|
|
|
preview_path = (
|
|
|
|
|
_render_png_with_magick(
|
|
|
|
|
run_dir,
|
|
|
|
|
pdf_path,
|
|
|
|
|
run_log,
|
|
|
|
|
section_title=f"{phase}.magick.preview",
|
|
|
|
|
png_name="preview.png",
|
|
|
|
|
size="1200x630",
|
|
|
|
|
)
|
|
|
|
|
if pdf_path
|
|
|
|
|
else None
|
|
|
|
|
)
|
|
|
|
|
elapsed_ms = int((time.monotonic() - started) * 1000)
|
|
|
|
|
|
|
|
|
|
_save_compile_state(
|
|
|
|
|
|