返回顶部
i

image-converter图片格式转换

图片格式转换工具。支持PNG、JPG、WEBP、SVG等格式互转。Use when user needs to convert image formats. 图片转换、格式转换、PNG转JPG、JPG转PNG。

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
131
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

image-converter

图片格式转换工具

支持PNG、JPG、WEBP、SVG等格式互转。

功能特点

  • - 🖼️ 多格式支持:PNG/JPG/WEBP/SVG/GIF/BMP
  • 🔄 双向转换:任意格式互转
  • 📦 批量转换:一次转换多个文件
  • 🎨 质量可控:自定义压缩质量
  • 快速转换:本地处理,无需网络

支持格式

格式输入输出说明
PNG无损压缩
JPG
✅ | ✅ | 有损压缩 | | WEBP | ✅ | ✅ | 现代格式 | | SVG | ⚠️ | ✅ | 矢量图 | | GIF | ✅ | ✅ | 动图 | | BMP | ✅ | ✅ | 位图 |

使用方式

User: 把这张PNG转成JPG
Agent: 转换图片格式

User: 把这些图片都转成WEBP
Agent: 批量转换

User: JPG转SVG
Agent: 转换为矢量图

Python代码

python
from PIL import Image
import os

class ImageConverter:
def init(self):
self.formats = {
png: PNG,
jpg: JPEG,
jpeg: JPEG,
webp: WEBP,
gif: GIF,
bmp: BMP
}

def convert(self, inputpath, outputpath, quality=95):
转换图片格式
img = Image.open(input_path)

# 获取输出格式
ext = os.path.splitext(output_path)[1].lower().replace(., )

if ext in [jpg, jpeg]:
# JPG需要RGB
if img.mode in (RGBA, LA, P):
img = img.convert(RGB)
img.save(output_path, JPEG, quality=quality)
elif ext == png:
img.save(output_path, PNG)
elif ext == webp:
img.save(output_path, WEBP, quality=quality)
elif ext == gif:
img.save(output_path, GIF)
elif ext == bmp:
img.save(output_path, BMP)
else:
img.save(output_path)

return output_path

def batchconvert(self, inputdir, outputdir, targetformat=jpg, quality=95):
批量转换
os.makedirs(outputdir, existok=True)

results = []
for filename in os.listdir(input_dir):
if filename.lower().endswith((.png, .jpg, .jpeg, .webp, .gif, .bmp)):
inputpath = os.path.join(inputdir, filename)
outputfilename = os.path.splitext(filename)[0] + f.{targetformat}
outputpath = os.path.join(outputdir, output_filename)

try:
self.convert(inputpath, outputpath, quality)
results.append({file: filename, status: success})
except Exception as e:
results.append({file: filename, status: error, error: str(e)})

return results

使用示例

converter = ImageConverter() converter.convert(input.png, output.jpg, quality=95)

注意事项

  • - 本地处理,无需网络
  • 支持批量转换
  • PNG转JPG会丢失透明度
  • SVG输出需要cairosvg

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 image-converter-1775931388 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 image-converter-1775931388 技能

通过命令行安装

skillhub install image-converter-1775931388

下载

⬇ 下载 image-converter v1.0.0(免费)

文件大小: 2.33 KB | 发布时间: 2026-4-12 10:15

v1.0.0 最新 2026-4-12 10:15
图片格式转换工具:支持PNG/JPG/WEBP/SVG/GIF/BMP互转,批量转换,质量可控

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部