yzsp-studio/mediakit-shared-suite / artifact-preview
artifact-preview
VerifiedRender workspace artifacts (pdf/pptx/docx/xlsx/html/png/jpg/txt/zip) into text + page screenshots + thumbnail + multi-page collages, saved under ./.preview/{hash}/. Use Read on the resulting jpg/png files to visually inspect your own deliverables before delivering them; it catches what a structural checker cannot — text truncation, colour clashes, clipped chart titles, layout drift, blank slides, CJK rendered as boxes. Triggered by: "看看产物长什么样", "视觉自检", "preview pptx", "render artifact", "screenshot pdf", "渲染产物", "我的报告画出来好看吗", "图表是否完整".
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 7.6 KB |
| SKILL.md | skill md | 10.1 KB |
| bin/preview | other | 2.0 KB |
| bin/preview.cmd | script | 482 B |
| lib/__init__.py | script | 1.7 KB |
| lib/_common.py | script | 13.1 KB |
| lib/_types.py | script | 3.5 KB |
| lib/cache.py | script | 3.3 KB |
| lib/cli.py | script | 10.2 KB |
| lib/collage.py | script | 4.6 KB |
| lib/dispatch.py | script | 8.3 KB |
| lib/docx.py | script | 1.1 KB |
| lib/html.py | script | 2.1 KB |
| lib/image.py | script | 1.4 KB |
| lib/manifest.py | script | 2.7 KB |
| lib/pdf.py | script | 2.2 KB |
| lib/pptx.py | script | 2.5 KB |
| lib/render/__init__.py | script | 2.4 KB |
| lib/render/collage.py | script | 10.9 KB |
| lib/render/constants.py | script | 1.4 KB |
| lib/render/docx.py | script | 2.2 KB |
| lib/render/html.py | script | 12.4 KB |
| lib/render/pdf.py | script | 3.4 KB |
| lib/render/pptx.py | script | 5.6 KB |
| lib/render/types.py | script | 1.3 KB |
| lib/render/xlsx.py | script | 2.9 KB |
| lib/text.py | script | 1.4 KB |
| lib/xlsx.py | script | 1.1 KB |
| lib/zip_.py | script | 1.4 KB |
| requirements.txt | manifest | 4.2 KB |
lib/pdf.py
View on GitHub"""PDF wrapper — IO + manifest layer over :mod:`render.pdf`."""
from __future__ import annotations
import logging
from pathlib import Path
from ._types import Manifest, PageImage, RenderOptions
from .dispatch import parse_page_range
from .render.pdf import extract_pdf
logger = logging.getLogger(__name__)
def render(
src: Path,
out_dir: Path,
opts: RenderOptions,
manifest: Manifest,
) -> None:
try:
pdf_bytes = src.read_bytes()
except Exception as exc:
manifest.warnings.append(f"failed to read pdf: {exc}")
return
# First parse with a permissive max so we don't throw away the user's
# spec; the shared lib re-clamps against the real ``total_pages`` it
# learns from PyMuPDF.
selected_pages = parse_page_range(opts.page_range, 10**6)
text, page_images, total_pages = extract_pdf(
pdf_bytes,
max_pages=opts.max_pages,
page_indices=selected_pages,
render_images=not opts.text_only,
)
if total_pages == 0 and not text:
manifest.warnings.append("pdf parse produced no pages or text")
return
manifest.page_count = total_pages
if not opts.text_only and page_images:
pages_dir = out_dir / "pages"
pages_dir.mkdir(exist_ok=True)
for pi in page_images:
png_path = pages_dir / f"p{pi.page:03}.png"
try:
png_path.write_bytes(pi.png_bytes)
except Exception as exc:
manifest.warnings.append(
f"pdf page {pi.page} write failed: {exc}",
)
continue
manifest.pages.append(PageImage(
page=pi.page,
relpath=str(png_path.relative_to(out_dir)),
size_bytes=png_path.stat().st_size,
width=pi.width,
height=pi.height,
))
if text:
text_path = out_dir / "text.md"
text_path.write_text(text, encoding="utf-8")
manifest.text_relpath = "text.md"
manifest.extracted_text_chars = len(text)
manifest.rendered_page_count = len(manifest.pages)
manifest.summary["total_pages"] = total_pages
manifest.summary["rendered_pages"] = manifest.rendered_page_count
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |