用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/vamseeachanta/workspace-hub --skill docx-templates-5-image-insertion命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Write outbound email and external messages in Vamsee Achanta's voice — a subtle offer to help, never bold or rash claims. Load before drafting ANY email, LinkedIn/Collide reply, proposal note, or outreach sent under his name.
Save/publish analysis or computation results from ANY ecosystem repo to Hugging Face as a queryable, viewer-renderable dataset. Use when the user wants to "save results to hugging face", "publish dataset to HF", "hugging face data saving", "save analysis results", "hf dataset", "make results queryable", or "render via datasets-server API". Reshapes nested results into flat parquet tables, writes a dataset card with a viewer `configs:` block and provenance, applies license/public-vs-private routing, enforces a domain data-quality gate (faithful-to-source != correct), publishes to `aceengineer/<repo>-<projection>`, and verifies via the datasets-server API.
Clone, create, fork, configure, and manage GitHub repositories. Manage remotes, secrets, releases, and workflows. Works with gh CLI or falls back to git + GitHub REST API via curl.
正在显示 SKILL.md
基于 SOC 职业分类
| name | docx-templates-5-image-insertion |
| description | Sub-skill of docx-templates: 5. Image Insertion. |
| version | 1.0.0 |
| category | data |
| type | reference |
| scripts_exempt | true |
Adding Images to Templates:
"""
Insert images into templates with proper sizing.
"""
from docxtpl import DocxTemplate, InlineImage
from docx.shared import Mm, Inches, Cm
from pathlib import Path
from typing import Optional, Union
from io import BytesIO
import requests
def add_image_to_template(
template_path: str,
output_path: str,
image_path: str,
context: dict,
width: Optional[Union[Mm, Inches, Cm]] = None,
height: Optional[Union[Mm, Inches, Cm]] = None
) -> None:
"""
Add an image to a template.
Template syntax:
{{ image }}
Args:
template_path: Path to template
output_path: Path for output
image_path: Path to image file
context: Additional context data
width: Image width (optional)
height: Image height (optional)
"""
template = DocxTemplate(template_path)
# Create InlineImage
image = InlineImage(
template,
image_path,
width=width,
height=height
)
# Add image to context
context["image"] = image
template.render(context)
template.save(output_path)
def add_image_from_url(
template: DocxTemplate,
url: str,
width: Optional[Mm] = None
) -> InlineImage:
"""
Create InlineImage from URL.
Args:
template: DocxTemplate instance
url: Image URL
width: Desired width
Returns:
InlineImage object
"""
response = requests.get(url)
response.raise_for_status()
image_stream = BytesIO(response.content)
return InlineImage(
template,
image_stream,
width=width
)
def render_document_with_images(
template_path: str,
output_path: str,
data: dict,
images: dict
) -> None:
"""
Render document with multiple images.
Template:
Company Logo: {{ logo }}
Product Images:
{% for product in products %}
{{ product.name }}: {{ product.image }}
{% endfor %}
"""
template = DocxTemplate(template_path)
# Process images
context = data.copy()
for key, image_info in images.items():
if isinstance(image_info, str):
# Simple path
context[key] = InlineImage(template, image_info, width=Mm(50))
elif isinstance(image_info, dict):
# Dict with path and dimensions
context[key] = InlineImage(
template,
image_info["path"],
width=image_info.get("width"),
height=image_info.get("height")
)
template.render(context)
template.save(output_path)
class ImageHandler:
"""
Handle images for template rendering.
"""
def __init__(self, template: DocxTemplate):
self.template = template
self._images: dict = {}
def add_image(
self,
key: str,
source: Union[str, BytesIO],
width: Optional[int] = None,
height: Optional[int] = None,
unit: str = "mm"
) -> 'ImageHandler':
"""
Add an image to the handler.
Args:
key: Context key for the image
source: File path or BytesIO stream
width: Width in specified units
height: Height in specified units
unit: Unit type ('mm', 'inches', 'cm')
"""
# Convert units
if unit == "mm":
w = Mm(width) if width else None
h = Mm(height) if height else None
elif unit == "inches":
w = Inches(width) if width else None
h = Inches(height) if height else None
elif unit == "cm":
w = Cm(width) if width else None
h = Cm(height) if height else None
else:
w = h = None
self._images[key] = InlineImage(
self.template,
source,
width=w,
height=h
)
return self
def add_image_from_url(
self,
key: str,
url: str,
width: int = 50,
unit: str = "mm"
) -> 'ImageHandler':
"""Add image from URL."""
response = requests.get(url)
response.raise_for_status()
image_stream = BytesIO(response.content)
return self.add_image(key, image_stream, width=width, unit=unit)
def get_context(self) -> dict:
"""Get images as context dictionary."""
*Content truncated — see parent skill for full reference.*