支援PNG、JPG、WEBP、SVG等格式互轉。
| 格式 | 輸入 | 輸出 | 說明 |
|---|---|---|---|
| PNG | ✅ | ✅ | 無失真壓縮 |
| JPG | ✅ | ✅ | 有失真壓縮 |
| WEBP | ✅ | ✅ | 現代格式 |
| SVG | ⚠️ | ✅ | 向量圖 |
| GIF | ✅ | ✅ | 動圖 |
| BMP | ✅ | ✅ | 點陣圖 |
User: "把這張PNG轉成JPG"
Agent: 轉換圖片格式
User: "把這些圖片都轉成WEBP"
Agent: 批次轉換
User: "JPG轉SVG"
Agent: 轉換為向量圖
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, input_path, output_path, 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 batch_convert(self, input_dir, output_dir, target_format='jpg', quality=95): """批次轉換""" os.makedirs(output_dir, exist_ok=True) results = [] for filename in os.listdir(input_dir): if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.webp', '.gif', '.bmp')): input_path = os.path.join(input_dir, filename) output_filename = os.path.splitext(filename)[0] + f'.{target_format}' output_path = os.path.join(output_dir, output_filename) try: self.convert(input_path, output_path, 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)7w4.net收錄了海量優質技能外掛。
這個圖片轉換工具整體質量中等偏上,支援多種常見格式,文件說明清晰。但存在一個致命問題:缺少 action 節點配置,導致它無法被 Agent 系統識別和呼叫。此外功能描述與程式碼實現有出入,聲稱支援 SVG 轉換但程式碼中沒有實現,批次處理功能也存在 bug。核心功能可用,但實用性和可靠性有待提升。