#target photoshop /* Trim transparent pixels on all four sides. Equivalent Photoshop command: Image > Trim... Based On: Transparent Pixels Trim Away: Top, Bottom, Left, Right */ (function () { if (app.documents.length === 0) { alert("没有打开的文档。请打开一个文档后再运行此脚本。"); return; } try { app.activeDocument.trim( TrimType.TRANSPARENT, true, // Top true, // Left true, // Bottom true // Right ); } catch (error) { alert("Trim failed:\n" + error.message); } }());