SuperAPI AI Directory

aws-wechat-article-images

Design & creation

View repository

Updated 10-16 03:12

About this skill

Inline image

WeChat Official Account cover & inline image AI generation — Automatically matches the art style to the article content; the style system is reusable.

Suite description · This skill belongs to the aws-wechat-article-* one-stop suite (9 slugs in total, entry point aws-wechat-article-main). Cross-skill relative references depend on the same skills/ directory; it is recommended to clawhub install the whole suite together. Source code:https://github.com/aiworkskills/wechat-article-skills

Capabilities

This skill calls image_create.py calls an external image API to generate covers and body inline images,and will send the image prompt (which may contain fragments of the article topic) to the user-configured image generation endpoint。

  • Credentials: reads aws.env 's IMAGE_MODEL_API_KEY, and sends it as Authorization: Bearer to image_model.base_url
  • Content egress: the prompt of each image is sent as the JSON POST body, from this article's imgs/prompts/*.md
  • SSRF defense: when the API returns an image URL,only http/https public addresses are allowed for download, and intranet / loopback / reserved addresses are all rejected
  • File read:.aws-article/config.yaml, this article's article.yaml / article.md / imgs/prompts/*.md, this skill's references/*、.aws-article/products/{产品名}/images/*
  • File write: this article's imgs/**, optional img_analysis.md
  • shell: only {python} {baseDir}/scripts/image_create.py、user_image_prepare.py

RecommendationUse a dedicated key (minimum privilege, separate billing); do not use an account-level master key.

When installing this skill separately, cross-skill references will file not found, but the image generation script is still usable. For the complete 9 slugs, see source code repository。

Routing

Complete long-form article from topic selection to publishing → main; image messages / multiple-image pushes such as nine-grid → sticker. This skill focuses onlong-form article inline images。

If the user says "I'm not satisfied with the inline images for this article; replace them with the new images I uploaded and resend to the drafts box" → do not use the workflow below; instead use Section 3 of branches.md, "Replace images and resend after publishing"。

Configuration check follows first-time onboarding for execution;image_model is in config.yaml、IMAGE_MODEL_API_KEY is in aws.env. For endpoint differences and how aspect ratios are passed, see Section 6 of branches.md。

Script Purpose
scripts/image_create.py Calls the dedicated image generation API (generate / batch / check / test)
scripts/user_image_prepare.py User-supplied images mode: create imgs/ and generate img_analysis.md template

Five hard rules ⛔

  1. The cover must be generated by script, and the output is cover.pngin the article directory (or .jpg / .jpeg / .webp)。Prohibitedto directly copy a material library file as cover.*. Exception: if the user explicitly uploads a cover and states "use only this one", the result must note "user-specified cover".
  2. For the body, prioritize the business inline image library, and only generate when images are missing. For the judgment order, see branches.md Section 1。
  3. There is a cap on deleting images: each article can have at most 1 image slot deleted, with the reason stated. To delete more than 2,or change this article's image_density to a smaller size(same effect), you must first tell the user the judgment that "this article's content and density don't match."
  4. imgs/ Directory division of labor: the root directory only holds final images referenced by the main text;prompts/ holds generation prompts,sources/ holds source notes for evidence images,raw/ holds intermediate products of screenshots and cropping.
  5. Divide labor first, then choose form: layout components and informational image slots do the same thing, so the same piece of content is given to only one of them. Butonly components reachable by standard markdown count—assigning to an unreachable component means both the image and the component fall through. For tested attributions see image-method step 1.5: onlyquote cardsgo to components; two-column comparisons and list key points always become images.

Workflow

配图进度:
- [ ] 第1步:读配置与文章
- [ ] 第2步:解析配图标记
- [ ] 第3步:确定风格
- [ ] 第4步:写 prompt
- [ ] 第5步:展示方案并等待确认 ⛔
- [ ] 第6步:生成图片
- [ ] 第7步:插入文章 + 收尾自检 ⛔

Step 1: Read configuration and article

  • Global .aws-article/config.yaml:cover_aspect、image_density、caption_style、tone etc. are subject to it (for fields see articlescreening-schema.md)。
  • This article article.yaml:default_cover_image_style(single element, this article's already-selected cover form),default_article_image_style(multi-element candidate pool, body forms are selected image slot by image slot,not converged into a single choice—converging means the whole article's images use the same form).
  • When reading article.md。
  • image_source: user , switch to branches.md Section 2 "User-supplied image mode"。

Step 2: Parse image markers

Extract all ![类型:描述](placeholder). Writers use only four types; they defineimage slots, not forms:

Type Meaning What this skill does
封面 Article cover Go to cover-method.md
实证 official original post screenshot, interface photo real material, do not generate; write the source note into imgs/sources/
信息图 information slot, explanatory content choose form by content, content must be taken from the article
氛围 rhythm slot, only to take a breather conceptual metaphor / scene reconstruction, no specific information

Old type names in existing drafts (流程图 / 对比) are handled as 信息图 .

Step 3: Determine style

First run once, to pick out unrecognizable form names in the candidate pool (without calling the API):

{python} {baseDir}/scripts/image_create.py styles

Exit code 1 indicates config.yaml 's candidate pool contains nonexistent names—rename first, then continue. In tested cases, a config exported by the website wrote "comparison explanation / blackboard whiteboard / atmosphere setting"; none of the three has a corresponding template (the real names are 对比两栏 / 概念隐喻 / 场景还原, while "blackboard whiteboard" is amediumnot a form). Picking such names can only leave the model to improvise freely, and the entire form methodology silently fails.

Cover and bodyare setseparately, each following its own preset directory. The loading priority for both is the same: user's specification for the current session > this article's article.yaml > custom_* candidate pool (empty means select all).

  • Cover: 12 built-in forms in references/cover-styles/(<名>.example.md), user-defined ones go in .aws-article/presets/cover-styles/, overwritten if names match. Each template containsused for subject / body / tone / copy / layoutfive fields,"copy" cannot be omitted—without it what is produced is a background image, not a cover. There is only one selection criterion: can the subject be recognized at a glance in a 345px thumbnail.
  • Body: 8 built-in forms in references/image-styles/. There is only one criterion: if this image is deleted, will readersfail to understand(information slot) orbe unable to keep reading(rhythm slot)? If neither is affected, delete that image slot.

Step 4: Write the prompt

  • Cover: follow cover-method.md through the first six steps and produce a prompt file—the frontmatter contains aspect(taken from cover_aspect,values must be quoted; unquoted 16:9 will be parsed by YAML as an integer), and the body is a 150–300 word prose passage, with the title copy (4–7 characters, character height occupying 25–35% of the frame) written into it along with position, font feel, and color. Do not use a keyword list, do not write "no X", and do not copy the example scenes.
  • Body: follow image-method.md to process each image slot one by one through the six steps.The content of information slots must be taken from the article—letting the model improvise will generate irrelevant chicken soup and include emoji.
  • Text in the image must be Chinese, and in the promptwrite directly the exact characters to be displayed, do not write "labels in Chinese".
  • For general rules (medium first, composition requirements, no redrawing with drawing libraries), see prompt-construction.md。

Step 5: Present the plan and wait for confirmation ⛔

  • One-stopand the user has no special style requirements: execute automatically with the default presetwithout separate confirmation, but the result must list each image's type, style, and prompt path.
  • Trigger this skill separately, the user has raised style requirements, or the plan involves replacing image slots with a business image library: first present the plan (position / type / style / prompt key points / source),wait for user confirmationthen proceed to step 6.

Step 6: Generate images

Inrepository rootexecute,write stdout and stderr to disk together:

{python} {baseDir}/scripts/image_create.py batch drafts/YYYYMMDD-slug/imgs/prompts/ \
  -o drafts/YYYYMMDD-slug/imgs/ > drafts/YYYYMMDD-slug/image-generation.log 2>&1

For a single image use generate <prompt.md> -o <out.png>; when rerunning in batch add --skip-existing, already generated and qualified ones will not be paid for again. For image specifications see specs.md。

First check the returned ratio and text completeness. The script defaults to fit: preserve, retaining the complete image returned by the API; a mismatched ratio will trigger a warning, and text will no longer be automatically cropped away. The target ratio must still be accepted before publishing. Only when you confirm the edges can be discarded, write in the frontmatter fit: crop or use --fit crop to restore centered cropping.generate、batch are both supported, with the command line taking priority. If text is missing, first determine whether the original image already had missing characters or whether it was caused by cropping; do not blindly regenerate when the retained image is already complete. For details see handling abnormal ratios and reviewable usage examples。

⛔ For text rendering problems, change the prompt first, do not switch tools. Do not switch to redrawing with matplotlib / PIL just because "the text produced by the API gets cropped"—that would bypass the entire methodology of medium and form, and you'd pay twice. For the reasoning, see prompt-construction.md。

Cover review (mandatory): open the image and check four things—subject position and title area, elements ≤3, thumbnail legibility, relevance to the article. If it fails,go back to the step where the problem occurred and revise the prompt before regenerating; do not blindly rerun without changing the prompt. If you cannot view the image, fall back to image_create.py check cover.png(only the two items of dimensions and near-monochrome)。

If the script exits non-zero or stderr has API / network errors → go to Section 4 of branches.md,you must classify and summarize the error, and must not just say "image generation failed".

Step 7: Insert into the article + final self-check

Replace the placeholder with the actual image path.The cover does not go into the body:![封面:…] and is used only for uploading as the WeChat cover; when replacing, skip or delete that line, and save the cover separately as the article root directory's cover.{ext}。

Only when article.html inthere actually exists href="placeholder" or the placeholder is rendered as a link should you fix the HTML; do not perform "fix HTML" by default every time.

⛔ Final self-check (six items, none may be missing)

  1. Each body image has one imgs/prompts/*.md, and the filename stem matches the image.Write the prompt to disk before generating; never the reverse—otherwise if a problem occurs you cannot reproduce it, and wanting to rerun just one image is impossible; you can only redo the whole batch (billed per image). When the Agent generates images itself, it must also write them to disk.
  2. Put the captions of evidentiary images in imgs/sources/, and do not put them in prompts/。batch , which is a whole-directory glob; mixing them in will follow "Source:https://x.com/…」生成一张**伪造的原帖截图**覆盖掉真的那张——而文章正拿它当证据。脚本已有防线(首行「来源:」或 frontmatter type: source will skip and warn), but placing the directory correctly is the fundamental fix.
  3. article.yaml of image_medium is non-empty, and equals the medium actually used in Step 4. It is the only basis for the next article to "avoid the previous article when tied".
  4. The number of body images matches image_density .If image slots were deleted, state which one was deleted and why.
  5. The generation log has been written to diskand you have checked whether there are truncation warnings. The reason the cover looks bad was pinpointed precisely from the log's "centered crop per 2.35:1: 1024x1024 → 1024x436"—scroll past it on screen and it's gone.
  6. imgs/ Only images referenced in the body remain in the root directory, and intermediate artifacts have been moved into raw/;All information-slot images in this article share the same medium, while the form of each image slot is chosen individually according to its content.

After rerunning image generationyou must recheck the references—the return format can change (PNG this time, JPEG next time), and the references will break without reporting an error. For details, see Section 5 of branches.md。

Branches and exceptions

All situations not on the main path are written in references/branches.md: body image source priority, user-supplied image mode, replacing images and republishing after publication, four categories of call failures, failure-degradation endpoints, rerun recheck, endpoint differences, and how to pass aspect ratios.