smart-image-loader

Smart image loader that handles both URLs and local files, automatically downloads URLs to temporary locations, and displays images using the read tool. Use when a user wants to view or display an image, whether it's a web URL or a file in the workspace.

MIT-0 · Free to use, modify, and redistribute. No attribution required.
1 · 1.7k · 1 current installs · 2 all-time installs
MIT-0
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description match the code and instructions: the script downloads HTTP(S) URLs to a temp dir, verifies local files, returns a path for the read tool, and SKILL.md explains that workflow. No unrelated binaries, env vars, or credentials are requested.
Instruction Scope
Instructions stay within the image-loading/displaying scope. One thing to note: SKILL.md recommends using shell exec with 'rm <file_path>' for cleanup — this is reasonable for removing temp files but grants the agent permission to run file-deletion commands on whatever path the skill returns. Also the script attempts cleanup in some error paths but uses an incorrect pattern (see code issue) so temporary directories may not be removed as intended.
Install Mechanism
No install specification — instruction-only plus a small Python script. No downloads, package installs, or external installers are performed.
Credentials
No environment variables, credentials, or config paths are requested. Network access is needed only to download image URLs, which is proportionate to the stated purpose.
Persistence & Privilege
always is false and the skill does not request persistent/system-wide changes or modify other skills' configs. It only reads workspace files and writes temporary files during URL downloads.
Assessment
This skill appears to do exactly what it says: download image URLs to a temp folder or validate local files and return a path for the agent's read tool. Before installing, consider: (1) the agent will be able to fetch arbitrary URLs — if you need to restrict hosts, enforce that at the agent/network layer; (2) the SKILL.md suggests using 'rm <file_path>' to clean up temp files — ensure the agent is not allowed to remove sensitive paths and only deletes paths returned by the script; (3) the script has a minor bug: on a URL-download error it calls cleanup_file(os.path.join(temp_dir, '*')) which won't remove the temp directory and is a no-op; a proper cleanup would use shutil.rmtree(temp_dir) or remove the exact file path; and (4) there are no requested credentials or external installs. If you want extra assurance, review or test the script in a sandboxed workspace and consider hardening path validation and cleanup logic before use.

Like a lobster shell, security has layers — review code before you run it.

Current versionv1.0.0
Download zip
latestvk978gtskqgwhr35007b7nd3m5580fh29

License

MIT-0
Free to use, modify, and redistribute. No attribution required.

SKILL.md

Smart Image Loader

Quick Start

When a user asks to display an image:

  1. Check if input is a URL or local path

    • URLs start with http:// or https://
    • Local paths are file paths in the workspace
  2. For URLs:

    • Download the image to a temporary location using the Python script
    • Use read tool to display the image
    • Clean up the temporary file afterward
  3. For local files:

    • Verify the file exists (relative to workspace or absolute path)
    • Use read tool directly to display the image

Usage Examples

User says: "Show me this image: https://example.com/photo.jpg"

  1. Run: python3 scripts/smart_image_loader.py https://example.com/photo.jpg
  2. Script downloads to temp: /tmp/dir/photo.jpg
  3. Use read tool on: /tmp/dir/photo.jpg
  4. Clean up: Delete the temp file

User says: "Display ./images/logo.png"

  1. Run: python3 scripts/smart_image_loader.py ./images/logo.png
  2. Script verifies file exists
  3. Use read tool on: /home/node/clawd/images/logo.png (absolute path)

Script Usage

python3 scripts/smart_image_loader.py <image_path_or_url>

Arguments

ArgumentDescription
image_path_or_urlEither a local file path (relative or absolute) or a URL

Output Format

The script returns a JSON-like output with:

  • Status: SUCCESS or FAILED
  • Type: url or local
  • File Path: Local path for the read tool
  • Message: Status description
  • Cleanup Needed: true if temp file should be deleted

Examples

# URL example
python3 scripts/smart_image_loader.py https://example.com/image.jpg
# Output: Downloads to /tmp/xyz/image.jpg, use read tool on that path

# Local file example (relative)
python3 scripts/smart_image_loader.py ./photos/vacation.jpg
# Output: File found at /home/node/clawd/photos/vacation.jpg

# Local file example (absolute)
python3 scripts/smart_image_loader.py /home/node/clawd/downloads/graphic.png
# Output: File found at /home/node/clawd/downloads/graphic.png

Workflow Decision Tree

User asks to display an image
         |
         v
    Is it a URL? (http:// or https://)
         |
    +----+---------------------------+
    |                                 |
   YES                               NO
    |                                 |
    v                                 v
Download to temp              Does file exist?
    |                                 |
    v                          +-----+-----+
Use read tool                 |           |
    |                        YES          NO
    v                              |
Cleanup temp file              v
                           Use read tool
                               |
                               v
                          Done (no cleanup)

Cleanup Guidelines

  • URL downloads: Always clean up temporary files after displaying
  • Local files: No cleanup needed (files remain in workspace)
  • Use exec with rm <file_path> for cleanup

Image Formats Supported

  • JPEG (.jpg, .jpeg)
  • PNG (.png)
  • GIF (.gif)
  • WebP (.webp)
  • BMP (.bmp)

Error Handling

ScenarioAction
URL download failsReport error to user
Local file not foundReport error to user
Invalid inputShow usage instructions

Files

2 total
Select a file
Select a file to preview.

Comments

Loading comments…