← 返回 Skills 市场
tobewin

Image Resizer

作者 ToBeWin · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
134
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install image-size-resizer
功能描述
图片分辨率调整工具。Use when user needs to resize images to specific dimensions. Supports custom size, batch resize, aspect ratio preservation. 图片缩放、分辨率调整、图片裁剪。
使用说明 (SKILL.md)

图片分辨率调整工具

根据用户要求调整图片分辨率,支持自定义尺寸和批量处理。

功能特点

  • 📐 自定义尺寸:任意宽度×高度
  • 🔄 保持比例:可选保持原始比例
  • 📦 批量处理:一次调整多个图片
  • 🎯 预设尺寸:常用尺寸快速选择
  • 高质量缩放:LANCZOS算法

预设尺寸

用途 尺寸 说明
微信头像 640×640 方形
微博头像 200×200 方形
淘宝主图 800×800 方形
抖音封面 1080×1920 竖版
朋友圈 1080×1080 方形
小红书 1080×1440 竖版
A4文档 2480×3508 A4 300dpi

使用方式

User: "把这张图片调整为640×640"
Agent: 调整图片尺寸

User: "帮我把这些图片都改成1080宽度,保持比例"
Agent: 批量调整宽度

User: "生成微信头像尺寸"
Agent: 调整为640×640

Python代码

from PIL import Image
import os

class ImageResizer:
    def __init__(self):
        self.presets = {
            'wechat_avatar': (640, 640),
            'weibo_avatar': (200, 200),
            'taobao_main': (800, 800),
            'douyin_cover': (1080, 1920),
            'friends_circle': (1080, 1080),
            'xiaohongshu': (1080, 1440),
            'a4_300dpi': (2480, 3508),
        }
    
    def resize(self, input_path, output_path, width=None, height=None, 
               keep_ratio=True, preset=None):
        """调整图片尺寸"""
        
        img = Image.open(input_path)
        
        # 使用预设尺寸
        if preset and preset in self.presets:
            width, height = self.presets[preset]
        
        # 计算尺寸
        if width and height:
            if keep_ratio:
                # 保持比例
                ratio = min(width / img.width, height / img.height)
                new_width = int(img.width * ratio)
                new_height = int(img.height * ratio)
            else:
                new_width = width
                new_height = height
        elif width:
            ratio = width / img.width
            new_width = width
            new_height = int(img.height * ratio)
        elif height:
            ratio = height / img.height
            new_width = int(img.width * ratio)
            new_height = height
        else:
            new_width = img.width
            new_height = img.height
        
        # 高质量缩放
        resized = img.resize((new_width, new_height), Image.LANCZOS)
        
        # 保存
        ext = os.path.splitext(output_path)[1].lower()
        if ext in ['.jpg', '.jpeg']:
            if resized.mode == 'RGBA':
                resized = resized.convert('RGB')
            resized.save(output_path, 'JPEG', quality=95)
        else:
            resized.save(output_path)
        
        return output_path
    
    def batch_resize(self, input_dir, output_dir, width=None, height=None, 
                     keep_ratio=True, preset=None):
        """批量调整尺寸"""
        os.makedirs(output_dir, exist_ok=True)
        
        results = []
        for filename in os.listdir(input_dir):
            if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.webp')):
                input_path = os.path.join(input_dir, filename)
                output_path = os.path.join(output_dir, filename)
                
                try:
                    self.resize(input_path, output_path, width, height, keep_ratio, preset)
                    results.append({'file': filename, 'status': 'success'})
                except Exception as e:
                    results.append({'file': filename, 'status': 'error', 'error': str(e)})
        
        return results

# 使用示例
resizer = ImageResizer()

# 自定义尺寸
resizer.resize('input.jpg', 'output.jpg', width=640, height=640)

# 保持比例
resizer.resize('input.jpg', 'output.jpg', width=1080, keep_ratio=True)

# 使用预设
resizer.resize('input.jpg', 'output.jpg', preset='wechat_avatar')

Notes

  • 使用LANCZOS算法,高质量缩放
  • 支持批量处理
  • 保持比例避免变形
  • 本地处理,无需网络
安全使用建议
This skill appears to be a straightforward local image-resizer implemented with Python/Pillow. Before installing, ensure you: (1) trust the skill source (it's instruction-only with no homepage), (2) have python3 and are willing to install the Pillow package via pip, and (3) will provide the agent only the image files/directories you want processed (the agent needs read/write access to those paths). There are no network calls or credential requests in the SKILL.md, so it does not appear to exfiltrate data, but avoid giving it access to sensitive images unless you trust the environment that will run the code.
功能分析
Type: OpenClaw Skill Name: image-size-resizer Version: 1.0.0 The skill is a standard image resizing utility using the Pillow library. The Python code in SKILL.md implements basic image manipulation, including aspect ratio preservation and batch processing, without any suspicious network activity, file system abuse, or obfuscation.
能力评估
Purpose & Capability
Name/description (image resizing, presets, batch processing) match the content of SKILL.md and the included Python example. Required binary (python3) and the listed dependency (Pillow) are appropriate and proportional to the stated purpose.
Instruction Scope
SKILL.md contains concrete Python code that reads image files from provided paths, resizes them, and writes outputs. Instructions do not reference unrelated files, environment variables, credentials, or external endpoints; the notes explicitly state local processing only.
Install Mechanism
This is an instruction-only skill with no install spec or downloads. The SKILL.md mentions 'pip install pillow' as a dependency; that is reasonable and low risk compared with downloading arbitrary binaries or archives.
Credentials
The skill declares no required environment variables, credentials, or config paths. That is proportionate for a local image-resizing utility.
Persistence & Privilege
The skill is not marked 'always:true' and requests no elevated or persistent system-wide privileges. Its runtime behavior (local file I/O, no config modification) is limited in scope.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install image-size-resizer
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /image-size-resizer 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
图片分辨率调整工具:自定义尺寸,保持比例,批量处理,预设常用尺寸
元数据
Slug image-size-resizer
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Image Resizer 是什么?

图片分辨率调整工具。Use when user needs to resize images to specific dimensions. Supports custom size, batch resize, aspect ratio preservation. 图片缩放、分辨率调整、图片裁剪。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 134 次。

如何安装 Image Resizer?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install image-size-resizer」即可一键安装,无需额外配置。

Image Resizer 是免费的吗?

是的,Image Resizer 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Image Resizer 支持哪些平台?

Image Resizer 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Image Resizer?

由 ToBeWin(@tobewin)开发并维护,当前版本 v1.0.0。

💬 留言讨论