{"id":228,"date":"2025-03-18T22:49:00","date_gmt":"2025-03-18T13:49:00","guid":{"rendered":"https:\/\/cg-method.com\/photoshop\/?p=228"},"modified":"2025-03-18T22:49:00","modified_gmt":"2025-03-18T13:49:00","slug":"conbine-layer","status":"publish","type":"post","link":"https:\/\/cg-method.com\/photoshop\/conbine-layer\/","title":{"rendered":"Photoshop\u30b9\u30af\u30ea\u30d7\u30c8\uff08jsx\uff09\u2502\u30ec\u30a4\u30e4\u30fc\u306e\u4e00\u756a\u4e0a\u306b\u3042\u308b\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u3092\u5404\u30d1\u30fc\u30c4\u30ec\u30a4\u30e4\u30fc\u306b\u9069\u7528\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"\n<p>Photoshop\u3067 <strong>\u30ec\u30a4\u30e4\u30fc\u306e\u4e00\u756a\u4e0a\u306b\u3042\u308b\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u3092\u3001\u5404\u30d1\u30fc\u30c4\u5206\u3051\u3055\u308c\u305f\u30ec\u30a4\u30e4\u30fc\u306b\u9069\u7528<\/strong> \u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 <strong>\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u30a4\u30e9\u30b9\u30c8\u306e\u4ed5\u4e0a\u3052\u3084\u3001Live2D\u306e\u30d1\u30fc\u30c4\u4f5c\u6210\u6642\u306b\u5f79\u7acb\u3064<\/strong> \u30c4\u30fc\u30eb\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f7f\u7528\u3059\u308b\u30e1\u30ea\u30c3\u30c8<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4e00\u62ec\u3067\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u3092\u5404\u30d1\u30fc\u30c4\u30ec\u30a4\u30e4\u30fc\u306b\u9069\u7528\u3067\u304d\u308b<\/strong><\/li>\n\n\n\n<li><strong>\u624b\u4f5c\u696d\u3067\u306f\u96e3\u3057\u3044\u5927\u91cf\u306e\u30d1\u30fc\u30c4\u51e6\u7406\u3092\u81ea\u52d5\u5316<\/strong><\/li>\n\n\n\n<li><strong>\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4fee\u6b63\u3059\u308c\u3070\u3001\u7279\u5b9a\u306e\u30ec\u30a4\u30e4\u30fc\u306b\u306e\u307f\u9069\u7528\u3082\u53ef\u80fd<\/strong><\/li>\n<\/ul>\n\n\n\n<p><strong>\u6ce8\u610f\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7d50\u5408\u5148\u306e\u30ec\u30a4\u30e4\u30fc\u304c\u975e\u8868\u793a\u3060\u3068\u9069\u7528\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u4e8b\u524d\u306b\u8868\u793a\u72b6\u614b\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068<\/strong><\/li>\n\n\n\n<li><strong>\u30ec\u30a4\u30e4\u30fc\u69cb\u9020\u304c\u8907\u96d1\u306a\u5834\u5408\u306f\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3059\u308b\u524d\u306b\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3092\u53d6\u308b\u3053\u3068\u3092\u63a8\u5968<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u30ec\u30a4\u30e4\u30fc\u306e\u4e00\u756a\u4e0a\u306e\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u3092\u9069\u7528<\/h2>\n\n\n\n<p>\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f7f\u3048\u3070\u3001 <strong>\u5404\u30d1\u30fc\u30c4\u30ec\u30a4\u30e4\u30fc\u3054\u3068\u306b\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u3092\u9069\u7528\u3057\u3001\u7d71\u5408<\/strong> \u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">STEP.1 \u30b9\u30af\u30ea\u30d7\u30c8\u3092\u683c\u7d0d<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4e0b\u8a18\u306e\u30b3\u30fc\u30c9\u3092\u30e1\u30e2\u5e33\u7b49\u306b\u30b3\u30d4\u30da\u3057\u3066\u4fdd\u5b58<\/li>\n<\/ol>\n\n\n\n<p><strong>ConbineLayer.jsx<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><code>app.bringToFront();\n\nif (app.documents.length === 0) {\n    \/\/ \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304c\u958b\u304b\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u51e6\u7406\u3092\u3057\u306a\u3044\u3002\n} else {\n    var doc = activeDocument;\n    \n    \/\/ \u30b0\u30ed\u30fc\u30d0\u30eb\u306a\u30ec\u30a4\u30e4\u30fc\u30ea\u30b9\u30c8\uff08\u5168\u30ec\u30a4\u30e4\u30fc\u3001\u9078\u629e\u30ec\u30a4\u30e4\u30fc\u3001\u7d50\u5408\u5bfe\u8c61\u30ec\u30a4\u30e4\u30fc\uff09\n    var allLayers = [];\n    var selectedLayers = [];\n    var targetLayers = [];\n\n    \/\/ \u5168\u30ec\u30a4\u30e4\u30fc\u3092\u518d\u5e30\u7684\u306b\u53ce\u96c6\n    collectAllLayers(doc);\n\n    \/\/ \u9078\u629e\u30ec\u30a4\u30e4\u30fc\u3092\u53d6\u5f97\n    collectSelectedLayers(selectedLayers);\n\n    \/\/ \u5168\u30ec\u30a4\u30e4\u30fc\u304b\u3089\u9078\u629e\u30ec\u30a4\u30e4\u30fc\u3092\u9664\u5916\u3057\u3001\u7d50\u5408\u5bfe\u8c61\u30ec\u30a4\u30e4\u30fc\u3092\u6c7a\u5b9a\n    filterTargetLayers(targetLayers);\n\n    if (selectedLayers == null || allLayers == null) {\n        alert(&quot;\u7d50\u5408\u3055\u305b\u308b\u30ec\u30a4\u30e4\u30fc\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002\\n\u51e6\u7406\u3092\u30ad\u30e3\u30f3\u30bb\u30eb\u3057\u307e\u3059\u3002&quot;);\n    } else {\n        \/\/ \u7d50\u5408\u5bfe\u8c61\u30ec\u30a4\u30e4\u30fc\u306b\u975e\u8868\u793a\u30ec\u30a4\u30e4\u30fc\u304c\u3042\u308b\u5834\u5408\u306f\u51e6\u7406\u4e2d\u65ad\n        var allVisible = true;\n        for (var i = 0; i &lt; targetLayers.length; i++) {\n            if (!targetLayers[i].visible) {\n                allVisible = false;\n                break;\n            }\n        }\n        if (!allVisible) {\n            alert(&quot;\u7d50\u5408\u5bfe\u8c61\u306e\u30ec\u30a4\u30e4\u30fc\u306b\u975e\u8868\u793a\u306e\u30ec\u30a4\u30e4\u30fc\u304c\u3042\u308a\u307e\u3059\u3002\\n\u975e\u8868\u793a\u30ec\u30a4\u30e4\u30fc\u306f\u7d50\u5408\u3067\u304d\u307e\u305b\u3093\u306e\u3067\u3001\u524a\u9664\u3059\u308b\u304b\u8868\u793a\u72b6\u614b\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\\n\\n\u51e6\u7406\u3092\u30ad\u30e3\u30f3\u30bb\u30eb\u3057\u307e\u3059\u3002&quot;);\n        } else {\n            var message = &quot;&quot;;\n            for (var i = 0; i &lt; selectedLayers.length; i++) {\n                message += selectedLayers[i].name + &quot; [&quot; + (selectedLayers.length - i) + &quot;]\\n&quot;;\n            }\n            message += &quot;\u3092\u3059\u3079\u3066\u306e\u30ec\u30a4\u30e4\u30fc\u306b\u7d50\u5408\u3057\u307e\u3059\u3002\uff08[]\u5185\u306e\u6570\u5b57\u306f\u7d50\u5408\u9806\uff09\\n\\n\u3088\u308d\u3057\u3044\u3067\u3059\u304b\uff1f\\n\\n\u3010\u6ce8\u610f\u3011\\n\u7d50\u5408\u3055\u305b\u305f\u3044\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u306f\u5168\u3066\u30ec\u30a4\u30e4\u30fc\u306e\u4e00\u756a\u4e0a\u306b\u914d\u7f6e\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;;\n\n            if (confirm(message)) {\n                doc.suspendHistory(&quot;\u7d50\u5408\u51e6\u7406&quot;, &quot;mergeLayers()&quot;);\n                alert(&quot;\u7d50\u5408\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002\\n\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u306f\u975e\u8868\u793a\u306b\u3057\u3066\u3044\u307e\u3059\u3002&quot;);\n            } else {\n                alert(&quot;\u51e6\u7406\u304c\u30ad\u30e3\u30f3\u30bb\u30eb\u3055\u308c\u307e\u3057\u305f\u3002&quot;);\n            }\n        }\n    }\n}\n\n\/\/ \u5404\u7d50\u5408\u5bfe\u8c61\u30ec\u30a4\u30e4\u30fc\u306b\u5bfe\u3057\u3066\u3001\u9078\u629e\u30ec\u30a4\u30e4\u30fc\u3092\u8907\u88fd\u30fb\u79fb\u52d5\u30fb\u7d50\u5408\u3059\u308b\nfunction mergeLayers() {\n    for (var i = 0; i &lt; targetLayers.length; i++) {\n        var backIndex = selectedLayers.length - 1;\n        for (var j = 0; j &lt; selectedLayers.length; j++) {\n            selectedLayers[backIndex - j].duplicate();\n            doc.activeLayer = activeDocument.layers[backIndex - j];\n            activeDocument.layers[backIndex - j].move(targetLayers[i], ElementPlacement.PLACEBEFORE);\n\n            try {\n                \/\/ \u30ec\u30a4\u30e4\u30fc\u30af\u30ea\u30c3\u30d4\u30f3\u30b0\u51e6\u7406\n                var idGrpL = charIDToTypeID(&quot;GrpL&quot;);\n                var desc = new ActionDescriptor();\n                var idnull = charIDToTypeID(&quot;null&quot;);\n                var ref = new ActionReference();\n                var idLyr = charIDToTypeID(&quot;Lyr &quot;);\n                var idOrdn = charIDToTypeID(&quot;Ordn&quot;);\n                var idTrgt = charIDToTypeID(&quot;Trgt&quot;);\n                ref.putEnumerated(idLyr, idOrdn, idTrgt);\n                desc.putReference(idnull, ref);\n                executeAction(idGrpL, desc, DialogModes.NO);\n            } catch (e) {\n                \/\/ \u30af\u30ea\u30c3\u30d4\u30f3\u30b0\u51e6\u7406\u5931\u6557\u6642\u306f\u7121\u8996\n            }\n            doc.activeLayer.merge();\n        }\n    }\n    \/\/ \u7d50\u5408\u5f8c\u3001\u5143\u306e\u9078\u629e\u30ec\u30a4\u30e4\u30fc\u3092\u975e\u8868\u793a\u306b\u3059\u308b\n    for (var i = 0; i &lt; selectedLayers.length; i++) {\n        selectedLayers[i].visible = false;\n    }\n}\n\n\/\/ \u9078\u629e\u30ec\u30a4\u30e4\u30fc\u3092\u53ce\u96c6\uff08\u30b0\u30eb\u30fc\u30d7\u5316\u30a4\u30d9\u30f3\u30c8\u3092\u5229\u7528\uff09\nfunction collectSelectedLayers(selectedLayersArray) {\n    if (doc.activeLayer) {\n        var idGrp = stringIDToTypeID(&quot;groupLayersEvent&quot;);\n        var descGrp = new ActionDescriptor();\n        var refGrp = new ActionReference();\n        refGrp.putEnumerated(charIDToTypeID(&quot;Lyr &quot;), charIDToTypeID(&quot;Ordn&quot;), charIDToTypeID(&quot;Trgt&quot;));\n        descGrp.putReference(charIDToTypeID(&quot;null&quot;), refGrp);\n        executeAction(idGrp, descGrp, DialogModes.ALL);\n\n        for (var i = 0; i &lt; doc.activeLayer.layers.length; i++) {\n            selectedLayersArray.push(doc.activeLayer.layers[i]);\n        }\n        undoAction();\n    }\n}\n\n\/\/ \u30a2\u30af\u30b7\u30e7\u30f3\u3092\u5143\u306b\u623b\u3059\nfunction undoAction() {\n    executeAction(charIDToTypeID(&quot;undo&quot;), undefined, DialogModes.NO);\n}\n\n\/\/ \u5168\u30ec\u30a4\u30e4\u30fc\u304b\u3089\u9078\u629e\u30ec\u30a4\u30e4\u30fc\u3092\u9664\u5916\u3057\u3001\u7d50\u5408\u5bfe\u8c61\u306e\u30ec\u30a4\u30e4\u30fc\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\nfunction filterTargetLayers(targetLayersArray) {\n    for (var i = 0; i &lt; allLayers.length; i++) {\n        var isSelected = false;\n        for (var j = 0; j &lt; selectedLayers.length; j++) {\n            if (allLayers[i].name === selectedLayers[j].name) {\n                isSelected = true;\n                break;\n            }\n        }\n        if (!isSelected) {\n            targetLayersArray.push(allLayers[i]);\n        }\n    }\n}\n\n\/\/ \u518d\u5e30\u7684\u306b\u5168\u30ec\u30a4\u30e4\u30fc\u3092\u53ce\u96c6\nfunction collectAllLayers(layerContainer) {\n    var childLayers = layerContainer.layers;\n    for (var i = 0; i &lt; childLayers.length; i++) {\n        if (childLayers[i].typename === &quot;LayerSet&quot;) {\n            \/\/ \u30ec\u30a4\u30e4\u30fc\u30bb\u30c3\u30c8\u306e\u5834\u5408\u306f\u518d\u5e30\u51e6\u7406\n            collectAllLayers(childLayers[i]);\n        } else if (childLayers[i].typename === &quot;ArtLayer&quot;) {\n            allLayers.push(childLayers[i]);\n        }\n    }\n}\n<\/code><\/pre><\/div>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><code>ConbineLayer.jsx<\/code> \u3092 <strong>\u4ee5\u4e0b\u306e\u30d5\u30a9\u30eb\u30c0\u306b\u4fdd\u5b58<\/strong>\u3002<\/li>\n<\/ol>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>C:\\Program Files\\Adobe\\Adobe Photoshop CC\\Presets\\Scripts\\<\/code><\/pre><\/div>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Photoshop\u3092\u518d\u8d77\u52d5\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">STEP.2 \u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>[\u30d5\u30a1\u30a4\u30eb]<\/strong> \u2192 <strong>[\u30b9\u30af\u30ea\u30d7\u30c8]<\/strong> \u2192 <strong>[ConbineLayer]<\/strong> \u3092\u9078\u629e\u3002<\/li>\n\n\n\n<li><strong>\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u304c\u5404\u30d1\u30fc\u30c4\u30ec\u30a4\u30e4\u30fc\u306b\u9069\u7528\u3055\u308c\u307e\u3059\u3002<\/strong><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u30ec\u30a4\u30e4\u30fc\u306e\u4e00\u756a\u4e0a\u306e\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u3092\u3001\u3059\u3079\u3066\u306e\u30d1\u30fc\u30c4\u30ec\u30a4\u30e4\u30fc\u306b\u9069\u7528\u53ef\u80fd<\/strong><\/li>\n\n\n\n<li><strong>\u9069\u7528\u5f8c\u306b\u81ea\u52d5\u3067\u7d71\u5408\u3059\u308b\u305f\u3081\u3001\u4f5c\u696d\u52b9\u7387\u304c\u5927\u5e45\u306b\u5411\u4e0a<\/strong><\/li>\n\n\n\n<li><strong>Live2D\u3084\u30a4\u30e9\u30b9\u30c8\u5236\u4f5c\u306b\u6700\u9069\u306a\u30b9\u30af\u30ea\u30d7\u30c8<\/strong><\/li>\n<\/ul>\n\n\n\n<p>Photoshop\u306e\u4f5c\u696d\u3092\u52b9\u7387\u5316\u3059\u308b\u305f\u3081\u306b\u3001 <strong>\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u6d3b\u7528\u3057\u3066\u52b9\u7387\u7684\u306b\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u3092\u9069\u7528<\/strong> \u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\uff01<\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Photoshop\u3067 \u30ec\u30a4\u30e4\u30fc\u306e\u4e00\u756a\u4e0a\u306b\u3042\u308b\u52b9\u679c\u30ec\u30a4\u30e4\u30fc\u3092\u3001\u5404\u30d1\u30fc\u30c4\u5206\u3051\u3055\u308c\u305f\u30ec\u30a4\u30e4\u30fc\u306b\u9069\u7528 \u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u30a4\u30e9\u30b9\u30c8\u306e\u4ed5\u4e0a\u3052\u3084\u3001Live2D\u306e\u30d1\u30fc\u30c4\u4f5c\u6210\u6642\u306b\u5f79\u7acb\u3064 \u30c4\u30fc\u30eb\u3067\u3059\u3002 \u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f7f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":229,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[2],"tags":[9],"class_list":["post-228","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-layer-operation","tag-free"],"_links":{"self":[{"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/posts\/228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/comments?post=228"}],"version-history":[{"count":1,"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":230,"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/posts\/228\/revisions\/230"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/media\/229"}],"wp:attachment":[{"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/media?parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/categories?post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cg-method.com\/photoshop\/wp-json\/wp\/v2\/tags?post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}