{"id":670,"date":"2025-07-25T16:23:43","date_gmt":"2025-07-25T08:23:43","guid":{"rendered":"https:\/\/rayray.moe\/?p=670"},"modified":"2026-02-21T19:12:20","modified_gmt":"2026-02-21T11:12:20","slug":"pi-liang-dao-ru-wen-jian-dao-illustrator-bing-tian","status":"publish","type":"post","link":"https:\/\/rayray.moe\/?p=670","title":{"rendered":"\u6279\u91cf\u5bfc\u5165\u6587\u4ef6\u5230 Illustrator \u5e76\u6dfb\u52a0\u6587\u4ef6\u540d\u7684\u811a\u672c"},"content":{"rendered":"<p>\u5728\u9047\u5230\u5927\u91cf\u6570\u636e\u7684\u7ed8\u56fe\u4e0e\u6392\u7248\u95ee\u9898\u65f6, \u501f\u52a9\u811a\u672c\u53ef\u4ee5\u89e3\u51b3\u8bb8\u591a\u95ee\u9898. \u76ee\u524d\u6211\u4e3b\u8981\u4f7f\u7528 Matlab \u8fdb\u884c\u6570\u636e\u5904\u7406\u7ed8\u56fe, \u4f7f\u7528 Illustrator \u8fdb\u884c\u6392\u7248. Illustrator \u63d0\u4f9b\u4e86\u4e00\u4e2a&quot;\u7f6e\u5165&quot;\u529f\u80fd, \u80fd\u591f\u5c06\u8bb8\u8bb8\u591a\u591a\u7684\u6587\u4ef6\u4e00\u53e3\u6c14\u90fd\u653e\u8fdb\u540c\u4e00\u4e2a\u6587\u6863\u4e2d, \u4f46\u662f\u5982\u679c\u8fd9\u4e9b\u6587\u4ef6\u957f\u5f97\u5f88\u50cf, \u653e\u8fdb\u53bb\u540e\u5206\u4e0d\u6e05\u600e\u4e48\u529e?<br \/>\n\u56e0\u6b64, \u5728\u548c GPT \u8c08\u4e86\u4e00\u4f1a\u513f\u5fc3\u540e, \u5199\u4e86\u8fd9\u6bb5\u811a\u672c\u7528\u4e8e\u6279\u91cf\u5bfc\u5165\u6587\u4ef6. \u8fd9\u4e2a\u811a\u672c\u80fd\u591f\u5c06\u9009\u5b9a\u7684\u6587\u4ef6\u5939\u5185\u90e8\u652f\u6301\u7684\u6587\u4ef6\u4e00\u53e3\u6c14\u5bfc\u5165\u5230\u4e00\u4e2a\u65b0\u5efa\u7684 AI \u6587\u4ef6\u4e2d, \u540c\u65f6\u5728\u4e0a\u9762\u9644\u4e0a\u6587\u4ef6\u540d, \u65b9\u4fbf\u540e\u7eed\u6392\u7248. \u811a\u672c\u4e0d\u957f, \u76f4\u63a5\u9644\u5728\u4e0b\u9762\u4e86.<\/p>\n<p>\u5c06\u8fd9\u4e2a\u6587\u4ef6\u4fdd\u5b58\u4e3a\u540e\u7f00\u4e3a .jsx \u7684\u6587\u4ef6, \u7136\u540e\u4f7f\u7528<strong>\u6587\u4ef6-&gt;\u811a\u672c-&gt;\u5176\u5b83\u811a\u672c<\/strong>\u8fd0\u884c. \u6ce8\u610f\u4e0b\u9762\u7684\u5b57\u4f53\u540d\u79f0\u9700\u8981\u662f\u672c\u673a\u6709\u7684\u5b57\u4f53\u624d\u884c, \u5426\u5219\u4f1a\u62a5\u9519.<br \/>\n\u6b64\u5916, \u5982\u679c\u9700\u8981\u505a\u6279\u91cf\u7684\u88c1\u8fb9\u548c\u4fee\u6539\u6587\u4ef6, \u4e5f\u53ef\u4ee5\u7528 PS \u7684\u6279\u5904\u7406\u65b9\u6cd5\u89e3\u51b3.<\/p>\n<pre><code class=\"language-JavaScript\">#target illustrator\n\n\/\/ \u9009\u62e9\u6587\u4ef6\u5939\nvar folder = Folder.selectDialog(&quot;\u8bf7\u9009\u62e9\u5305\u542b\u56fe\u7247\u7684\u6587\u4ef6\u5939&quot;);\nif (!folder) exit();\n\n\/\/ \u652f\u6301\u7684\u6587\u4ef6\u6269\u5c55\u540d\nvar validExtensions = ['.pdf', '.png', '.tif', '.tiff', '.jpg', '.jpeg'];\n\n\/\/ \u8bfb\u53d6\u6587\u4ef6\nvar imageFiles = folder.getFiles(function (f) {\n    if (!(f instanceof File)) return false;\n    var ext = f.name.slice(f.name.lastIndexOf('.')).toLowerCase();\n    for (var j = 0; j &lt; validExtensions.length; j++) {\n    if (ext === validExtensions[j]) return true;\n    }\n    return false;\n});\nif (imageFiles.length === 0) {\n    alert(&quot;\u672a\u627e\u5230\u56fe\u50cf\u6587\u4ef6&quot;);\n    exit();\n}\n\n\/\/ \u7f51\u683c\u53c2\u6570\nvar columns = 6;                        \/\/ \u6bcf\u884c\u56fe\u50cf\u6570\u91cf\uff08\u53ef\u8c03\uff09\nvar cellWidth = 595;\nvar cellHeight = 842;\nvar spacingX = 50;\nvar spacingY = 50;\nvar margin = 40;\nvar rows = Math.ceil(imageFiles.length \/ columns);\n\n\/\/ \u753b\u5e03\u5c3a\u5bf8\u81ea\u9002\u5e94\nvar artboardWidth = columns * (cellWidth + spacingX);\nvar artboardHeight = rows * (cellHeight + spacingY);\n\n\/\/ \u521b\u5efa\u6587\u6863\u548c\u56fe\u5c42\nvar doc = app.documents.add(DocumentColorSpace.RGB);\ndoc.artboards[0].artboardRect = [0, artboardHeight, artboardWidth, 0];\nvar labelLayer = doc.layers.add();\nlabelLayer.name = &quot;Labels&quot;;\n\n\/\/ \u4e3b\u5faa\u73af\uff1a\u63d2\u56fe+\u6807\u6ce8\nfor (var i = 0; i &lt; imageFiles.length; i++) {\n    var file = imageFiles[i];\n    var filename = decodeURI(file.name.replace(\/\\.[^\\.]+$\/, &quot;&quot;)); \/\/ \u53bb\u9664\u6269\u5c55\u540d\n\n    \/\/ \u7f51\u683c\u4f4d\u7f6e\n    var col = i % columns;\n    var row = Math.floor(i \/ columns);\n    var originX = col * (cellWidth + spacingX);\n    var originY = artboardHeight - (row + 1) * (cellHeight + spacingY);\n\n    \/\/ \u6bcf\u4e2a\u6587\u4ef6\u5355\u72ec\u56fe\u5c42\n    var layer = doc.layers.add();\n    layer.name = filename;\n    doc.activeLayer = layer;\n\n    try {\n        \/\/ \u63d2\u5165\u56fe\u50cf\n        var placed = doc.placedItems.add();\n        placed.file = file;\n\n        \/\/ \u7f29\u653e\n        var maxW = cellWidth - 2 * margin;\n        var maxH = cellHeight - 2 * margin;\n        var scale = Math.min(maxW \/ placed.width, maxH \/ placed.height, 1.0);\n        placed.width *= scale;\n        placed.height *= scale;\n\n        \/\/ \u5bf9\u9f50\u5de6\u4e0b\u89d2\u951a\u70b9\n        var posX = originX + (cellWidth - placed.width) \/ 2;\n        var posY = originY + (cellHeight - placed.height) \/ 2;\n        placed.position = [posX, posY];\n        placed.embed();\n\n        \/\/ \u6dfb\u52a0\u6807\u7b7e\u6587\u672c\n        doc.activeLayer = labelLayer;\n        var text = doc.textFrames.add();\n        text.contents = filename;\n        text.textRange.characterAttributes.size = 10;\n        text.textRange.characterAttributes.textFont = app.textFonts.getByName(&quot;Helvetica&quot;);\n        text.paragraphs[0].justification = Justification.LEFT;\n\n        \/\/ \u653e\u7f6e\u4e8e\u56fe\u50cf\u4e0b\u65b9\n        text.position = [posX, posY - 20];\n\n    } catch (e) {\n        alert(&quot;\u5904\u7406\u5931\u8d25\uff1a&quot; + file.name + &quot;\\n&quot; + e);\n    }\n}\n\nalert(&quot;\u6210\u529f\u5bfc\u5165 &quot; + imageFiles.length + &quot; \u4e2a\u56fe\u50cf\u6587\u4ef6\uff01&quot;);\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u9047\u5230\u5927\u91cf\u6570\u636e\u7684\u7ed8\u56fe\u4e0e\u6392\u7248\u95ee\u9898\u65f6, \u501f\u52a9\u811a\u672c\u53ef\u4ee5\u89e3\u51b3\u8bb8\u591a\u95ee\u9898. \u76ee\u524d\u6211 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-notes"],"_links":{"self":[{"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rayray.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=670"}],"version-history":[{"count":2,"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions"}],"predecessor-version":[{"id":698,"href":"https:\/\/rayray.moe\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions\/698"}],"wp:attachment":[{"href":"https:\/\/rayray.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rayray.moe\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rayray.moe\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}