name: image-upscale description: AI-powered image upscaling using Real-ESRGAN + LANCZOS. Supports PSD/PNG/JPG input, generates high-resolution PNG with configurable DPI. Use when the user asks to upscale, enlarge, magnify, or increase resolution of images; when working with print-ready images requiring high DPI; when converting PSD to high-resolution PNG; or when image quality enhancement with AI-generated detail is needed.
AI图像放大技能,基于 Real-ESRGAN 神经网络 + LANCZOS 插值。
向用户确认两个参数: 1. 放大倍数或目标尺寸 — 默认 10x(即最终尺寸 = 原图 ×10) 2. 目标 DPI — 默认 300(打印级)
如果用户提供的是目标长宽像素,计算所需倍数:scale = ceil(target / original)。
(dpi, dpi) 元数据{basename}_{scale}x_{dpi}DPI_realesrgan.pngscripts/upscale.py主脚本,包含完整推理代码:
- upscale_image() — 单图处理
- batch_upscale() — 批量处理
- download_model() — 自动下载模型
- 纯 PyTorch 实现,无需额外依赖(只需 torch + Pillow + numpy + requests)
# 单图
python scripts/upscale.py input.png -o output.png -s 10 -d 300
# 批量
python scripts/upscale.py ./images/ --batch -s 10 -d 300
# CPU 模式
python scripts/upscale.py input.png --device cpu
from scripts.upscale import upscale_image, batch_upscale
# 单图
result = upscale_image('input.psd', 'output.png', target_scale=10, target_dpi=300)
# 批量
results = batch_upscale('./images/', target_scale=10, target_dpi=300)
scripts/ 目录scripts/RealESRGAN_x4plus.pth这个图像放大工具质量不错,操作流程清晰易懂,放大效果有保障。它支持 PSD、PNG、JPG 等常见格式,还能自动下载所需模型。用 AI 生成细节再配合数学插值,放大后的图像质量较好。文档写得很详细,小白也能上手。不过首次使用需要下载较大文件,没有依赖列表文件,部分细节功能还需要手动调整。建议准备好网络环境再使用。