Token导航 LogoToken导航TokenDH.com
图像处理只读github未标认证来源可访问clear审计通过

code-from-image代码 from 图像

Agent Skill

用于辅助图像生成、图片编辑、视觉素材处理或图像模型工作流。它适合让 Agent 根据文本生成图片、处理背景、整理视觉提示词或调用相关图像工具。使用时需要确认输入图片、版权来源、输出格式和模型限制;涉及人物、品牌、商品或公开展示素材时,应额外核对授权、真实性和内容合规边界。

总安装

2,165

周安装

93

GitHub Stars

93

下载量

759
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:code-from-image(代码 from 图像)
来源仓库:https://github.com/letta-ai/skills
仓库路径:skills/code-from-image
安装命令:
npx skills add https://github.com/letta-ai/skills --skill code-from-image
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/letta-ai/skills --skill code-from-image

简介

code-from-image 提供从图像中提取代码或伪代码的指导,涵盖 OCR 工具选择与结果验证策略。

  • 适用于将截图、白板或文档图片中的代码转换为可运行脚本,常用于教学或遗留系统迁移。
  • 支持多种包管理器与图像处理库,优先检测 tesseract、pytesseract 和 Pillow 环境可用性。
  • 使用前请确认图像清晰度与版权合法性,输出结果需经人工校验以避免 OCR 错误导致运行时问题。
  • 本技能不保证 100% 准确率,复杂布局或多语言混合内容建议分段处理并交叉验证语法正确性。

SKILL.md

Code From Image

Overview

This skill provides guidance for extracting code or pseudocode from images and implementing it correctly. It covers OCR tool selection, handling ambiguous text extraction, and verification strategies to ensure accurate implementation.

Workflow

Step 1: Environment Preparation

Before attempting to read an image, check available tools and packages:

  1. Check what package managers are available (pip, pip3, uv, conda)
  2. Check what image processing tools are installed (tesseract, pytesseract, PIL/Pillow)
  3. Install missing dependencies before proceeding

This avoids wasted attempts with unavailable tools.

Step 2: Image Analysis

Examine the image before OCR extraction:

  1. Use file <image> to verify the file type and ensure it's a valid image
  2. Open the image visually if possible to understand content structure
  3. Note the image quality, contrast, and text clarity

Step 3: OCR Extraction with Multiple Attempts

OCR is inherently error-prone. To maximize accuracy:

  1. First attempt: Use standard OCR (pytesseract with default settings)
  2. If output is garbled: Apply image preprocessing:

- Increase contrast - Convert to grayscale - Apply binarization (threshold) - Resize the image (2x or 3x upscaling can help)

  1. Compare outputs: If multiple OCR attempts yield different results, cross-reference them

Example preprocessing with PIL:

from PIL import Image, ImageEnhance, ImageFilter

img = Image.open("code.png")
# Convert to grayscale
img = img.convert("L")
# Increase contrast
enhancer = ImageEnhance.Contrast(img)
img = enhancer.enhance(2.0)
# Apply threshold for binarization
img = img.point(lambda x: 0 if x < 128 else 255, '1')
img.save("preprocessed.png")

Step 4: Interpreting OCR Output

OCR frequently produces character substitution errors. Document all interpretations explicitly:

Common OCR Misreadings:

  • 0 (zero) vs O (letter O) vs o (lowercase o)
  • 1 (one) vs l (lowercase L) vs I (uppercase i)
  • S vs 5 vs $
  • G vs 6
  • B vs 8
  • : vs ;
  • sha256 may appear as cha256 or sha2S6
  • Variable names may have incorrect characters (e.g., GALT instead of SALT)
  • Quote characters may be mangled (6" instead of b" for byte strings)
  • Array slicing may be garbled (h0[:10] appearing as hof:10])

Process for interpretation:

  1. List each unclear portion of the OCR output
  2. Document the most likely correct interpretation
  3. Explain reasoning for each interpretation
  4. Flag any interpretations with high uncertainty

Step 5: Implementation

When implementing the extracted code:

  1. Preserve the algorithm structure: Follow the logic as written, don't optimize prematurely
  2. Handle encoding explicitly: For cryptographic operations, be explicit about string vs bytes encoding
  3. Add basic error handling: Include try/except for file operations and external calls
  4. Log intermediate values: Print or log intermediate results for debugging

Step 6: Verification

Verify the implementation systematically:

  1. If a hint is provided (e.g., expected output prefix): Use it to validate, but don't rely on it exclusively
  2. Trace through the algorithm manually: Verify your understanding matches the implementation
  3. Test with known inputs: If possible, create test cases with predictable outputs
  4. Check edge cases: Empty inputs, special characters, boundary conditions

Warning: Using hints as the sole validation is brittle. A correct output prefix doesn't guarantee the algorithm is fully correct for all inputs.

Common Pitfalls

OCR-Related

  • Accepting first OCR output without verification: Always cross-check unclear characters
  • Not documenting assumptions: When interpreting garbled text, explicitly state what you're assuming
  • Skipping preprocessing: Image enhancement significantly improves OCR accuracy

Implementation-Related

  • String vs bytes confusion: In Python, cryptographic functions often require bytes (b"string") not strings
  • Missing imports: Ensure all required modules are imported before running
  • Silent failures: Add explicit error messages for file operations

Verification-Related

  • Over-relying on partial hints: A matching prefix doesn't mean the full output is correct
  • Not validating intermediate steps: Check values at each stage, not just the final output
  • Assuming OCR was correct: If output doesn't match expectations, revisit OCR interpretation

Fallback Strategy

If the initial interpretation produces incorrect results:

  1. Re-examine the original image, focusing on unclear characters
  2. Try alternative OCR preprocessing techniques
  3. List all ambiguous characters and test alternative interpretations systematically
  4. If multiple interpretations exist, implement and test each one

Example Workflow

For a task like "Extract pseudocode from image and compute hash":

  1. Check environment: which tesseract, pip3 list | grep -i pil
  2. Install if needed: pip3 install pillow pytesseract
  3. Analyze image: file code.png
  4. Extract text with OCR
  5. If garbled, preprocess image and retry OCR
  6. Document interpretations: "OCR shows GALT = 6"0000... - interpreting as SALT = b"0000..." because G/S confusion is common and 6" likely represents b" for bytes"
  7. Implement the algorithm
  8. Verify output against any provided hints
  9. If verification fails, revisit step 5-6 with alternative interpretations

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

28.55%
按下载量换算217

Gemini CLI

23.62%
按下载量换算179

Codex

18.78%
按下载量换算143

Antigravity

12.54%
按下载量换算95

OpenCode

7.56%
按下载量换算57

windsurf

3.39%
按下载量换算26

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills