English | 中文
Smart Layer Export 是一个用于 Adobe Photoshop 的 JSX 脚本,可将选中的图层或图层组批量导出为透明 PNG,并让所有导出文件保持统一的尺寸和坐标关系。
适用于游戏 UI、网页 UI、活动页面、图标、按钮、弹窗、角色分层及光效素材等批量切图场景。
- 批量导出当前选中的图层或图层组
- 自动识别选区导出和完整画布导出
- 保留图层在原 PSD 中的相对位置
- 所有导出的 PNG 使用统一尺寸
- 支持透明 PNG
- 导出后恢复原有图层可见状态
- 自动替换文件名中的非法字符
- 同名文件自动追加编号,不覆盖已有文件
- 不保存对原始 PSD 的临时可见性修改
文档中存在活动选区时,脚本按照选区的外接矩形导出。
PSD 画布:750 × 1624 px
当前选区:600 × 700 px
导出结果:每张 PNG 均为 600 × 700 px
不规则选区同样使用其外接矩形范围。
文档中没有活动选区时,脚本按照完整 PSD 画布导出。
PSD 画布:750 × 1624 px
导出结果:每张 PNG 均为 750 × 1624 px
这种方式适合将素材导入 Unity、Unreal、Cocos、After Effects 等软件后按原坐标重新叠放。
- 在 Photoshop 中打开 PSD。
- 如需局部导出,请先创建选区;如需完整画布导出,请取消选区。
- 在图层面板中选中一个或多个图层或图层组。
- 运行
Smart_Layer_Export.jsx。 - 选择输出文件夹。
- 等待导出完成。
每个选中的图层或图层组会生成一个独立的 PNG。
在 Photoshop 中选择:
文件 → 脚本 → 浏览…
然后选择 Smart_Layer_Export.jsx。
将脚本复制到 Photoshop 的脚本目录:
Adobe Photoshop/Presets/Scripts/
重新启动 Photoshop,然后通过以下菜单运行:
文件 → 脚本 → Smart_Layer_Export
Photoshop 的安装位置可能因操作系统和版本而异。
存在选区 → 复制临时文档 → 按选区外接矩形裁切 → 导出 → 关闭临时文档
没有选区 → 使用当前完整画布 → 直接导出
脚本会依次隐藏其他图层,仅显示当前导出目标及必要的父级。导出图层组时,会保留该组内子图层原有的可见状态。全部操作结束后,脚本会恢复原文档的图层可见状态。
PNG 使用对应的图层或图层组名称。下列文件名非法字符会被替换为下划线:
/ \ : * ? " < > |
同名文件会自动编号:
Button.png
Button_1.png
Button_2.png
- 建议在运行脚本前保存 PSD。
- 建议使用矩形选区,以便精确控制导出尺寸。
- 选区模式下,Photoshop 会短暂打开临时文档。
- 脚本运行期间会暂时改变原文档的图层可见性,并在结束后恢复。
- 图层组只导出组内原本可见的子图层。
- 调整图层、剪贴蒙版、图层效果及特殊混合模式的最终效果可能受到 PSD 图层结构影响,建议使用实际文件验证。
- 需要支持 JSX / ExtendScript 的 Photoshop 版本。
Smart Layer Export is an Adobe Photoshop JSX script that batch-exports selected layers or layer groups as transparent PNG files while preserving a consistent export size and coordinate system.
It is useful for game UI, web UI, campaign pages, icons, buttons, popups, character layers, VFX assets, and similar production workflows.
- Batch-export selected layers and layer groups
- Automatically switch between selection and full-canvas export
- Preserve each layer's relative position in the PSD
- Keep every exported PNG at a consistent size
- Support transparent PNG output
- Restore the original layer visibility after export
- Sanitize invalid filename characters
- Add numeric suffixes instead of overwriting existing files
When an active selection exists, the script exports the bounding rectangle of that selection. Irregular selections also use their rectangular bounds.
When no selection exists, the script exports each target using the full PSD canvas size. This preserves coordinates when the files are reassembled in Unity, Unreal, Cocos, After Effects, or other tools.
- Open a PSD in Photoshop.
- Create a selection for a local export area, or deselect everything for full-canvas export.
- Select one or more layers or layer groups in the Layers panel.
- Run
Smart_Layer_Export.jsx. - Choose an output folder.
- Wait for the export to finish.
Each selected layer or layer group is exported as an individual PNG.
Run the script temporarily from:
File → Scripts → Browse…
To add it to the Scripts menu, copy it to:
Adobe Photoshop/Presets/Scripts/
Restart Photoshop, then use:
File → Scripts → Smart_Layer_Export
The exact installation path depends on your operating system and Photoshop version.
- Save your PSD before running the script.
- Rectangular selections are recommended for exact dimensions.
- Temporary documents may appear briefly in selection mode.
- The script temporarily changes layer visibility and restores it when processing ends.
- When exporting a layer group, only children that were originally visible are included.
- Adjustment layers, clipping masks, layer effects, and special blend modes can depend on the surrounding PSD structure; verify complex documents with representative files.
- A Photoshop version with JSX / ExtendScript support is required.