{"id":2409,"date":"2018-11-19T05:39:58","date_gmt":"2018-11-18T20:39:58","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=2409"},"modified":"2020-03-19T02:12:21","modified_gmt":"2020-03-18T17:12:21","slug":"electron-%e3%81%a7%e3%82%a2%e3%83%8b%e3%83%a1gif%e3%82%92%e3%81%a4%e3%81%8f%e3%82%8b%e3%82%a2%e3%83%97%e3%83%aa","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=2409","title":{"rendered":"Electron \u3067\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b\u30a2\u30d7\u30ea\uff08\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\uff09"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u308c\u307e\u3067\u30a6\u30a7\u30d6\u304b\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3070\u304b\u308a\u306e\u958b\u767a\u3060\u3063\u305f\u306e\u304c<code>Electron<\/code>\u3067\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30a2\u30d7\u30ea\u3092\u958b\u767a\u3092\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3001\u307e\u3060\u307e\u3060\u8a66\u3057\u306b\u3084\u3063\u3066\u307f\u305f\u3044\u3053\u3068\u304c\u601d\u3044\u6d6e\u304b\u3093\u3067\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u7279\u306b<code>Electron<\/code>\u306f\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u305b\u305a\u306b\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u4e0a\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u30a2\u30af\u30bb\u30b9\u304c\u3067\u304d\u308b\u306e\u3067\u3001\u753b\u50cf\u3084\u30c6\u30ad\u30b9\u30c8\u306a\u3069\u30d5\u30a1\u30a4\u30eb\u95a2\u9023\u306e\u6a5f\u80fd\u3068\u89aa\u548c\u6027\u304c\u9ad8\u3044\u306e\u304b\u306a\u3068\u611f\u3058\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u4eca\u56de\u958b\u767a\u3059\u308b\u30a2\u30d7\u30ea\u306f\u300c<strong>\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b<\/strong>\u300d\u30a2\u30d7\u30ea\u3067\u3059\u3002<\/p>\n<p>\u30a2\u30cb\u30e1GIF\uff08animated gif\uff09\u3068\u306f\u3001\u52d5\u753b\u306e\u3088\u3046\u306b\u52d5\u304b\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u753b\u50cf\u306e\u3053\u3068\u3067\u3001\u6b21\u306e\u3088\u3046\u306a\u3082\u306e\u3067\u3059\u3002\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u3067\u3082\u73cd\u3057\u304f\u306a\u3044\u306e\u3067\u307f\u306a\u3055\u3093\u3082\u4e00\u5ea6\u306f\u898b\u305f\u3053\u3068\u304c\u3042\u308b\u3093\u3058\u3083\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2413 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/surprised_animated.gif\" alt=\"\" width=\"150\" height=\"132\" \/><\/p>\n<p>\u3053\u306e\u30a2\u30cb\u30e1GIF\u3001\u300c\u52d5\u304d\u3092\u898b\u305b\u305f\u3044\u3093\u3060\u3051\u3069\u3001JavaScript\u3068\u304b\u52d5\u753b\u306b\u3059\u308b\u307e\u3067\u3067\u3082\u306a\u3044\u3088\u306a\u30fb\u30fb\u30fb\u300d\u306a\u3093\u3066\u3068\u304d\u306b\u4f7f\u3048\u307e\u3059\u3002\u3057\u304b\u3082\u52d5\u753b\u307b\u3069\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u304c\u5927\u304d\u304f\u3082\u306a\u3044\u306e\u3067\u914d\u5e03\u3059\u308b\u306b\u3082\u90fd\u5408\u304c\u826f\u304b\u3063\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u30a2\u30cb\u30e1GIF\u3092\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30a2\u30d7\u30ea\u3092\u958b\u767a\u3057\u3066\u307f\u307e\u3059\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1785 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/15-2.png\" alt=\"\" width=\"226\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/15-2.png 226w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/15-2-212x300.png 212w\" sizes=\"auto, (max-width: 226px) 100vw, 226px\" \/><\/p>\n<p>\u203b \u958b\u767a\u74b0\u5883\uff1a Electron\u3001ImageMagick 6.9<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b\u3068\u3044\u3063\u3066\u3082\u3001\u305b\u3063\u304b\u304f<code>Electron<\/code>\u3067\u30a2\u30d7\u30ea\u3092\u4f5c\u308b\u306e\u3067\u3001\u6b21\u306e\u6a5f\u80fd\u3082\u3064\u3051\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u753b\u50cf\u3092\u30a2\u30d7\u30ea\u304b\u3089\u9078\u629e\u3067\u304d\u308b<\/li>\n<li>\u5207\u308a\u66ff\u308f\u308b\u753b\u50cf\u306e\u9806\u756a\u3092\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3067\u5909\u66f4\u3067\u304d\u308b<\/li>\n<li>\u753b\u50cf\u304c\u5207\u308a\u66ff\u308f\u308b\u9593\u9694\u3092\u6307\u5b9a\u3067\u304d\u308b<\/li>\n<\/ul>\n<p>\u306e\uff13\u3064\u3067\u3059\u3002<\/p>\n<h1>\u6e96\u5099<\/h1>\n<p>\u4eca\u56de\u3001\u5b9f\u969b\u30a2\u30cb\u30e1GIF\u306e\u4f5c\u6210\u306f<code>ImageMagick<\/code>\u3092\u4f7f\u3044\u307e\u3059\u3002<br \/>\n<span style=\"font-size: 1rem;\">\u305d\u306e\u305f\u3081\u3001\u4e8b\u524d\u306b<code>ImageMagick<\/code>\u304c\u4f7f\u3048\u308b\u3088\u3046\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/span><\/p>\n<p>\u79c1\u306e\u540c\u3058\u304fUbuntu\u74b0\u5883\u3067\u3057\u305f\u3089\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>sudo apt install imagemagick<\/strong><\/pre>\n<h1>Electron\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h1>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u3001<a href=\"https:\/\/blog.capilano-fw.com\/?p=2054\">\u521d\u5fc3\u8005\u5411\u304d\uff01electron \u3067\u7c21\u5358\u306a\u30e1\u30e2\u5e33\u3092\u3064\u304f\u3063\u3066\u307f\u3088\u3046<\/a>\u306e <strong>&#8220;electron\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb&#8221;<\/strong> \u306b\u8a73\u3057\u304f\u66f8\u3044\u3066\u3042\u308b\u306e\u3067\u3001\u305d\u3061\u3089\u3092\u898b\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u30d5\u30a9\u30eb\u30c0\u540d\u306f<code>anime-gif-maker<\/code>\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2414\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/Screenshot-from-2018-11-15-02-12-49.png\" alt=\"\" width=\"217\" height=\"129\" \/><\/p>\n<h1>\u30a2\u30d7\u30ea\u306e\u8a2d\u5b9a<\/h1>\n<p><code>main.js<\/code>\u3092\u958b\u3044\u3066\u30a6\u30a3\u30f3\u30c9\u30a6\u30b5\u30a4\u30ba\u3001\u4f4d\u7f6e\u3001\u30e1\u30cb\u30e5\u30fc\u30d0\u30fc\u306e\u975e\u8868\u793a\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>mainWindow = new BrowserWindow({<\/strong>\r\n<strong>    width: 500,<\/strong>\r\n<strong>    height: 500,<\/strong>\r\n<strong>    x: 0,<\/strong>\r\n<strong>    y: 0,<\/strong>\r\n<strong>    autoHideMenuBar: true,\r\n    webPreferences: {\r\n        preload: path.join(__dirname, 'preload.js'),\r\n        nodeIntegration: true\r\n    }<\/strong>\r\n<strong>})<\/strong><\/pre>\n<p><strong>\u3010\u8ffd\u8a18\uff1a2020.3.19\u3011<\/strong><code>Electron v5<\/code>\u4ee5\u964d\u306e\u305f\u3081\u306b<code>webPreferences<\/code>\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u307e\u305f\u3001\u79c1\u306e\u74b0\u5883\u306e\u3088\u3046\u306bLinux\u3092\u4f7f\u3063\u3066\u3044\u308b\u3068\u30a2\u30d7\u30ea\u4e0a\u3067\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3059\u308b\u3068\u30af\u30e9\u30c3\u30b7\u30e5\u3057\u3066\u3057\u307e\u3046\u30d0\u30b0\u304c\u3042\u308b\u306e\u3067\u3001<code>app.disableHardwareAcceleration()<\/code>\u3092\u4f7f\u3063\u3066\u3053\u308c\u3092\u56de\u907f\u3057\u3066\u304a\u304d\u307e\u3059\u3002\uff08\u3069\u3046\u3084\u3089\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u30fb\u30a2\u30af\u30bb\u30e9\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u539f\u56e0\u306e\u3088\u3046\u3067\u3059\uff09<\/p>\n<pre>const {app, BrowserWindow} = require('electron')\r\n\r\n<strong>app.disableHardwareAcceleration()<\/strong><\/pre>\n<h1>CSS\u3001JS\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af<\/h1>\n<p>\u30ec\u30a4\u30a2\u30a6\u30c8\u7528\u306b<code>bootstrap<\/code>\u3001JavaScript\u7528\u306b<code>Vue<\/code>\u3001\u305d\u3057\u3066\u8981\u7d20\u3092\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3067\u4e26\u3079\u66ff\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b<code>sortablejs<\/code>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>npm i bootstrap --save\r\nnpm i vue --save\r\nnpm i sortablejs --save\r\n<\/strong><\/pre>\n<h1>\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001<code>bootstrap<\/code>\u3092\u4f7f\u3063\u3066\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<pre>&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"UTF-8\"&gt;\r\n    &lt;title&gt;\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b\u30a2\u30d7\u30ea\uff01&lt;\/title&gt;\r\n    <strong>&lt;link rel=\"stylesheet\" href=\".\/node_modules\/bootstrap\/dist\/css\/bootstrap.min.css\"&gt;<\/strong>\r\n    &lt;style&gt;\r\n\r\n        body {\r\n            padding: 15px 0;\r\n        }\r\n\r\n        #image-container {\r\n            background: #eee;\r\n            padding: 15px;\r\n            border-radius: 5px;\r\n            height: 300px;\r\n        }\r\n\r\n        #time {\r\n            width: 200px;\r\n        }\r\n\r\n        #button {\r\n            width: 150px;\r\n            position: absolute;\r\n            right: 15px;\r\n            bottom: 20px;\r\n        }\r\n\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div id=\"app\" class=\"container\"&gt;\r\n    <strong>&lt;select id=\"time\" class=\"form-control float-right\"&gt;<\/strong>\r\n<strong>        &lt;option&gt;\u5207\u308a\u66ff\u308f\u308a\uff081\/100\u79d2\uff09&lt;\/option&gt;<\/strong>\r\n<strong>    &lt;\/select&gt;<\/strong>\r\n    <strong>&lt;label class=\"btn btn-light\"&gt;<\/strong>\r\n<strong>        \u753b\u50cf\u3092\u8ffd\u52a0&lt;input type=\"file\" accept=\"image\/*\" multiple hidden&gt;<\/strong>\r\n<strong>    &lt;\/label&gt;<\/strong>\r\n    &lt;hr&gt;\r\n    &lt;label&gt;\u8868\u793a\u9806\u3092\u4e26\u3079\u66ff\u3048\u308b\uff08\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3067\u304d\u307e\u3059\uff09&lt;\/label&gt;\r\n    <strong>&lt;div id=\"image-container\"&gt;<\/strong>\r\n<strong>        \uff08\u3053\u3053\u306b\u753b\u50cf\u30ea\u30b9\u30c8\uff09<\/strong>\r\n<strong>    &lt;\/div&gt;<\/strong>\r\n    <strong>&lt;button id=\"button\" type=\"button\" class=\"btn btn-dark\"&gt;\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b&lt;\/button&gt;<\/strong>\r\n&lt;\/div&gt;\r\n&lt;script&gt;\r\n    require('.\/renderer.js')\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u307e\u305a\u753b\u50cf\u3092\u9078\u629e\u3059\u308b\u30dc\u30bf\u30f3\u3067\u3059\u304c\u3001\u901a\u5e38\u306e<code>&lt;input type=\"file\"&gt;<\/code>\u3067\u306f\u306a\u304f\u3001\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3053\u3068\u3067\u300c\u30d5\u30a1\u30a4\u30eb\u9078\u629e\u30c0\u30a4\u30a2\u30ed\u30b0\u300d\u304c\u8868\u793a\u3055\u308c\u308b\u30c6\u30af\u30cb\u30c3\u30af\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u30d5\u30a1\u30a4\u30eb\u9078\u629e\u3067\u304d\u308b\u306e\u306f<code>accept=\"image\/*\"<\/code>\u3067\u753b\u50cf\u3060\u3051\u306b\u5236\u9650\u3057\u3001<code>multiple<\/code>\u3067\u8907\u6570\u9078\u629e\u3092\u8a31\u53ef\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001<code>&lt;select&gt;<\/code>\u3067\u753b\u50cf\u304c\u5207\u308a\u66ff\u308f\u308b\u9593\u9694\u3092\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3001\u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u306e\u30ea\u30b9\u30c8\u306f\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3067\u9806\u756a\u3092\u5165\u308c\u66ff\u3048\u3089\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u753b\u50cf\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2416\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/Screenshot-from-2018-11-15-03-44-24.png\" alt=\"\" width=\"502\" height=\"532\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/Screenshot-from-2018-11-15-03-44-24.png 502w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/Screenshot-from-2018-11-15-03-44-24-283x300.png 283w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/p>\n<p>\u3067\u306f\u3001JavaScript\u90e8\u5206\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h1>JavaScript\u90e8\u5206\u3092\u3064\u304f\u308b<\/h1>\n<h2>Vue\u306e\u57fa\u672c\u5f62\u3092\u3064\u304f\u308b<\/h2>\n<p>\u307e\u305a\u306fVue\u3092\u8aad\u307f\u8fbc\u3093\u3067\u57fa\u672c\u5f62\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>&lt;script src=\".\/node_modules\/vue\/dist\/vue.min.js\"&gt;&lt;\/script&gt;<\/strong>\r\n<strong>&lt;script&gt;<\/strong>\r\n\r\n<strong>    new Vue({<\/strong>\r\n<strong>        el: '#app'<\/strong>\r\n<strong>    })<\/strong>\r\n\r\n<strong>&lt;\/script&gt;<\/strong><\/pre>\n<h2>\u753b\u50cf\u3092\u9078\u629e\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u6b21\u306b\u753b\u50cf\u306e\u9078\u629e\u90e8\u5206\u3067\u3059\u3002<br \/>\n<code>&lt;input type=\"file\"&gt;<\/code>\u306b\u30d5\u30a1\u30a4\u30eb\u304c\u9078\u629e\u3055\u308c\u305f\u3068\u304d\u306b\u5b9f\u884c\u3059\u308b<code>setImages()<\/code>\u3092\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3068\u3057\u3066\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;input type=\"file\" accept=\"image\/*\" <strong>@change=\"setImages($event)\"<\/strong> multiple hidden&gt;<\/pre>\n<p>\u305d\u3057\u3066\u3001<code>data<\/code>\u306b\u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30fc\u30bf\u304c\u5165\u308b<code>files<\/code>\u3092\u8ffd\u52a0\u3057\u3001\u3055\u3089\u306b<code>methods<\/code>\u306b\u3082<code>setImage()<\/code>\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>data: {\r\n    <strong>files: []<\/strong>\r\n},\r\nmethods: {\r\n    <strong>setImages(e) {<\/strong>\r\n<strong>        this.files = e.target.files<\/strong>\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u3053\u308c\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u9078\u629e\u3055\u308c\u305f\u3089\u81ea\u52d5\u7684\u306b<code>files<\/code>\u306b\u30c7\u30fc\u30bf\u304c\u53cd\u6620\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u5207\u308a\u66ff\u308f\u308a\u6642\u9593\u306e\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u6b21\u306b\u5207\u308a\u66ff\u308f\u308b\u9593\u9694\u3092\u9078\u629e\u3059\u308b\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u306e\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u307e\u305a<code>data<\/code>\u3078\u6642\u9593\u3092\u683c\u7d0d\u3059\u308b<code>time<\/code>\u3092\u8ffd\u52a0\u3002<br \/>\n<code>v-model<\/code>\u3067\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u3057\u307e\u3059\u3002<\/p>\n<pre>data: {\r\n    files: [],\r\n    <strong>time: 10<\/strong>\r\n}<\/pre>\n<p>\u305d\u3057\u3066\u3001\u3044\u3064\u3082\u306a\u3089<code>timeOptions<\/code>\u306a\u3069\u3068\u3057\u3066\u9078\u629e\u80a2\u3082\u8ffd\u52a0\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306f<code>v-for<\/code>\u306e\u6570\u5b57\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;select id=\"time\" class=\"form-control float-right\" <strong>v-model=\"time\"<\/strong>&gt;\r\n    &lt;option <strong>v-for=\"i in 10\" :value=\"i*10\"<\/strong>&gt;\u5207\u308a\u66ff\u308f\u308a\uff08<strong>{{ i\/10}}<\/strong> \u79d2\uff09&lt;\/option&gt;\r\n&lt;\/select&gt;<\/pre>\n<p>\u5b9f\u884c\u3057\u305f\u3082\u306e\u304c\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2417\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/Screenshot-from-2018-11-15-03-58-32.png\" alt=\"\" width=\"222\" height=\"262\" \/><\/p>\n<h2>\u753b\u50cf\u304c\u8868\u793a\u3055\u308c\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u753b\u50cf\u304c\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3067\u4e26\u3079\u66ff\u3048\u3089\u308c\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u306e\u3067\u3001\u5148\u307b\u3069\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f<code>sortablejs<\/code>\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n<pre><strong>window.Sortable = require('sortablejs')<\/strong><\/pre>\n<p>\u203b \u306a\u304a\u3001\u901a\u5e38\u306e<code>&lt;script src=\"***\"&gt;<\/code>\u3067\u306f\u3046\u307e\u304f\u3044\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u6b21\u306b\u3001\u753b\u50cf\u3092<code>v-for<\/code>\u3067\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;div id=\"image-container\"&gt;\r\n    <strong>&lt;img v-for=\"(file,index) in files\"<\/strong>\r\n<strong>         :src=\"file.path\"<\/strong>\r\n<strong>         :data-index=\"index\"<\/strong>\r\n<strong>         class=\"image\"&gt;<\/strong>\r\n&lt;\/div&gt;<\/pre>\n<p><code>data-index<\/code>\u306e\u90e8\u5206\u306f\u3001\u5f8c\u3067\u753b\u50cf\u306e\u9806\u756a\u3092\u6c7a\u3081\u308b\u6642\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u753b\u50cf\u304c\u9078\u629e\u3055\u308c\u305f\u3089<code>image-container<\/code>\u3078<code>Sortable<\/code>\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>setImages(e) {<\/strong>\r\n<strong>    this.files = e.target.files<\/strong>\r\n<strong>    Vue.nextTick(() =&gt; {<\/strong>\r\n<strong>        const el = document.getElementById('image-container')<\/strong>\r\n<strong>        Sortable.create(el)<\/strong>\r\n<strong>    })<\/strong>\r\n<strong>}<\/strong><\/pre>\n<p>\u203b \u306a\u304a\u3001<code>Vue.nextTick()<\/code>\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u306f\u3001\u78ba\u5b9f\u306b\u8868\u793a\u304cVue\u306b\u3088\u3063\u3066\u5909\u66f4\u3055\u308c\u305f\u5f8c\u3067<code>Sortable<\/code>\u3092\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n<p><span style=\"font-size: 1rem;\">\u3067\u306f\u3001\u4e00\u65e6\u3069\u3093\u306a\u98a8\u306b\u8868\u793a\u3055\u308c\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2419\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/Screenshot-from-2018-11-15-05-03-50.png\" alt=\"\" width=\"502\" height=\"532\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/Screenshot-from-2018-11-15-05-03-50.png 502w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/Screenshot-from-2018-11-15-05-03-50-283x300.png 283w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/p>\n<p>\u3046\u307e\u304f\u3044\u304d\u307e\u3057\u305f\uff01<br \/>\n\u30c9\u30e9\u30c3\u30b0\uff06\u30c9\u30ed\u30c3\u30d7\u3067\u753b\u50cf\u3092\u79fb\u52d5\u3055\u305b\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u3084\u3063\u3068\u672c\u984c\u306b\u305f\u3069\u308a\u3064\u304d\u307e\u3057\u305f\u3002<br \/>\n\u300c\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b\u300d\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3068\u304d\u306e\u30b3\u30fc\u30c9\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u3092\u3059\u308b\u30e2\u30b8\u30e5\u30fc\u30eb<code>fs<\/code>\u3001\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b<code>spawn<\/code>\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n<pre><strong>const fs = require('fs')\r\nconst {spawn} = require('child_process')\r\n<\/strong><\/pre>\n<p>\u306a\u304a\u3001<code>ImageMagick<\/code>\u306e\u30b3\u30de\u30f3\u30c9\u3067\u306f\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u9023\u756a\u306b\u306a\u3063\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308b\u305f\u3081\u3001<code>tmp<\/code>\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u3063\u3066\u304a\u304d\u3001\u3053\u3053\u3078\u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u3063\u3066\u304b\u3089\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2421\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/Screenshot-from-2018-11-15-05-20-33.png\" alt=\"\" width=\"379\" height=\"224\" \/><\/p>\n<p>\u305d\u3057\u3066\u3001<code>generateAnimatedGif()<\/code>\u304c\u5b9f\u884c\u3055\u308c\u308b\u30af\u30ea\u30c3\u30af\u30fb\u30a4\u30d9\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<pre>&lt;button \r\n    id=\"button\" \r\n    type=\"button\" \r\n    class=\"btn btn-dark\" \r\n    <strong>@click=\"generateAnimatedGif()\"<\/strong>&gt;\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b&lt;\/button&gt;<\/pre>\n<p><code>generateAnimatedGif()<\/code>\u3001\u305d\u306e\u4e2d\u3067\u547c\u3073\u51fa\u3059<code>refreshTempFiles()<\/code>\u3001<code>makeTempFiles()<\/code>\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>generateAnimatedGif()<\/strong> {\r\n    <strong>this.refreshTempFiles()<\/strong>\r\n<strong>    this.makeTempFiles()<\/strong>\r\n    const now = Date.now()\r\n    const tmpPathPattern = __dirname +'\/tmp\/*.png'\r\n    const outputPath = `${__dirname}\/animated_${now}.gif`\r\n<strong>    const command = `\/usr\/bin\/convert -delay ${this.time} -loop 0 -alpha remove ${tmpPathPattern} ${outputPath}`<\/strong>\r\n<strong>    const process = spawn('\/bin\/sh', ['-c', command])<\/strong>\r\n<strong>    process.on('close', (code) =&gt; {<\/strong>\r\n<strong>        if(code == 0) {<\/strong>\r\n<strong>            alert('\u30a2\u30cb\u30e1GIF\u304c\u4f5c\u6210\u3055\u308c\u307e\u3057\u305f\uff01');<\/strong>\r\n<strong>        }<\/strong>\r\n<strong>    });<\/strong>\r\n},\r\n<strong>refreshTempFiles()<\/strong> {\r\n    const tmpPath = __dirname +'\/tmp\/'\r\n    fs.readdirSync(tmpPath)\r\n        .forEach((file) =&gt; {\r\n            fs.unlinkSync(tmpPath + file)\r\n        })\r\n},\r\n<strong>makeTempFiles()<\/strong> {\r\n    const el = document.getElementById('image-container')\r\n    const images = el.childNodes\r\n    images.forEach((image, i) =&gt; {\r\n        let index = image.getAttribute('data-index')\r\n        let file = this.files[index]\r\n        let filename = i.toString().padStart(6, '0') +'.png'\r\n        let tempPath = __dirname +'\/tmp\/'+ filename\r\n        fs.copyFileSync(file.path, tempPath)\r\n    })\r\n}<\/pre>\n<p>\u307e\u305a<code>refreshTempFIles()<\/code>\u3067<code>tmp<\/code>\u30d5\u30a9\u30eb\u30c0\u5185\u306e\u5168\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001<code>makeTempFiles()<\/code>\u3067<code>image-container<\/code>\u306e\u4e2d\u306b\u3042\u308b\u753b\u50cf\u3092<code>childNodes<\/code>\u3067\u53d6\u5f97\u3057\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u3092\u9023\u756a\u3067\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001\u6700\u5f8c\u306b<code>spawn<\/code>\u3067\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u304c\u3001\u3053\u3053\u3067\u91cd\u8981\u306a\u306e\u304c<code>\/usr\/bin\/convert<\/code>\u3084<code>\/usr\/sh<\/code>\u306a\u3069\u306e\u30d1\u30b9\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\u306f\u3001<code>which sh<\/code>\u3084<code>which convert<\/code>\u306a\u3069\u3067\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u8868\u793a\u3055\u308c\u308b\u7d76\u5bfe\u30d1\u30b9\u3067\u3059\uff08Windows\u306e\u5834\u5408\u306f<code>where<\/code>\uff09\u3002\u30d1\u30b9\u304c\u901a\u3063\u3066\u3044\u308c\u3070\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u304c\u5ff5\u306e\u70ba\u3053\u306e\u5f62\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u5404\u81ea\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u306a\u304a\u3001\u4eca\u56de\u306e<code>convert<\/code>\u30b3\u30de\u30f3\u30c9\u306b\u306f<code>-alpha remove<\/code>\u3092\u3064\u3051\u3066\u900f\u904e\u90e8\u5206\u3092\u524a\u9664\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u4eca\u56de\u306e\u30a2\u30d7\u30ea\u3092\u4f7f\u3063\u3066\u4f5c\u6210\u3057\u305f\u30a2\u30cb\u30e1GIF\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u2193\u2193\u2193<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2424\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/animated_1542231807967.gif\" alt=\"\" width=\"306\" height=\"320\" \/><\/p>\n<p>\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f!<\/p>\n<h1>\u6559\u6750\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u5b9f\u969b\u306b\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b \u305f\u3060\u3057npm\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3084\u30a2\u30cb\u30e1GIF\u5316\u3059\u308b\u753b\u50cf\u306f\u3054\u81ea\u8eab\u3067\u7528\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=2426&amp;tmstv=1777531488\" rel=\"nofollow\" id=\"download-link-2426\" data-redirect=\"false\" >\n\tElectron \u3067\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b<\/a>\n\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u308c\u307e\u3067\u30a6\u30a7\u30d6\u304b\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3070\u304b\u308a\u306e\u958b\u767a\u3060\u3063\u305f\u306e\u304cElectron\u3067\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30a2\u30d7\u30ea\u3092\u958b\u767a\u3092\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3001\u307e\u3060\u307e\u3060\u8a66\u3057\u306b\u3084\u3063\u3066\u307f\u305f\u3044\u3053\u3068\u304c\u601d\u3044 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=2409\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Electron \u3067\u30a2\u30cb\u30e1GIF\u3092\u3064\u304f\u308b\u30a2\u30d7\u30ea\uff08\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\uff09&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":2434,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49,12,97],"tags":[113,83],"class_list":["post-2409","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-electron","category-vue-js","category-97","tag-gif","tag-83"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/2409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2409"}],"version-history":[{"count":13,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/2409\/revisions"}],"predecessor-version":[{"id":6239,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/2409\/revisions\/6239"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/2434"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}