{"id":1188,"date":"2024-06-12T18:07:20","date_gmt":"2024-06-12T09:07:20","guid":{"rendered":"https:\/\/shinke1987.net\/?p=1188"},"modified":"2024-06-13T10:30:49","modified_gmt":"2024-06-13T01:30:49","slug":"%e8%a4%87%e6%95%b0%e3%81%ae%e7%94%bb%e5%83%8f%e3%82%92%e4%b8%80%e6%8b%ac%e3%81%a7%e7%b7%a8%e9%9b%86%e3%81%99%e3%82%8b%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88","status":"publish","type":"post","link":"https:\/\/shinke1987.net\/?p=1188","title":{"rendered":"\u8907\u6570\u306e\u753b\u50cf\u3092\u4e00\u62ec\u3067\u7de8\u96c6\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8"},"content":{"rendered":"\n<h2 id=\"toc0\" class=\"wp-block-heading\">\u74b0\u5883<\/h2>\n\n\n\n<p>OS\uff1amacOS 14.5<\/p>\n\n\n\n<p>PHP\uff1a8.3.7 \uff08brew\u3092\u5229\u7528\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff09\uff08GD\u3084&#8211;with-freetype\u7b49\u304c\u6709\u52b9\u5316\u3055\u308c\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308b\uff09<\/p>\n\n\n\n<p>GoogleFonts\u7b49\u304b\u3089\u4f7f\u7528\u53ef\u80fd\u306a\u30d5\u30a9\u30f3\u30c8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3001<br>\u4eca\u56de\u4f5c\u6210\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3068\u540c\u3058\u30d5\u30a9\u30eb\u30c0\u3078\u914d\u7f6e\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n\n\n\n<h2 id=\"toc1\" class=\"wp-block-heading\">\u76ee\u7684<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>jpeg\u30d5\u30a1\u30a4\u30eb\u3092webp\u306b\u5909\u63db\u3059\u308b\u3002<\/li>\n\n\n\n<li>\u89e3\u50cf\u5ea6\u3092\u4e0b\u3052\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002\uff08\u4eca\u56de\u306f\u6a2a\u5e451000px\u306b\u5909\u66f4\u3057\u3001\u7e26\u5e45\u306f\u6bd4\u7387\u306b\u5fdc\u3058\u3066\u5909\u66f4\u3055\u308c\u308b\uff09<\/li>\n\n\n\n<li>\u6307\u5b9a\u3057\u305f\u7b87\u6240\u306b\u7279\u5b9a\u306e\u6587\u5b57\u5217\u3092\u8868\u793a\u3055\u305b\u308b\u3002<\/li>\n\n\n\n<li>\u8fd4\u9084\u524d\u306e\u753b\u50cf\u304c\u4fdd\u5b58\u3055\u308c\u305f\u30d5\u30a9\u30eb\u30c0\u3068\u3001\u5909\u63db\u5f8c\u306e\u753b\u50cf\u304c\u4fdd\u5b58\u3055\u308c\u308b\u30d5\u30a9\u30eb\u30c0\u3092\u6307\u5b9a\u3067\u304d\u308b\u3002<\/li>\n<\/ul>\n\n\n\n<h2 id=\"toc2\" class=\"wp-block-heading\">\u4f7f\u3044\u65b9<\/h2>\n\n\n\n<p>\u4e0b\u8a18\u30b3\u30fc\u30c9\u3092\u4fdd\u5b58\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u3067\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n% php \u30d5\u30a1\u30a4\u30eb\u540d.php \u5909\u63db\u524d\u306e\u753b\u50cf\u304c\u4fdd\u5b58\u3055\u308c\u305f\u30d5\u30a9\u30eb\u30c0 \u5909\u63db\u5f8c\u306e\u753b\u50cf\u304c\u4fdd\u5b58\u3055\u308c\u308b\u30d5\u30a9\u30eb\u30c0\n<\/pre><\/div>\n\n\n<h2 id=\"toc3\" class=\"wp-block-heading\">\u30b3\u30fc\u30c9<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\n\n\/\/ \u5909\u63db\u524d\u306e\u753b\u50cf\u304c\u4fdd\u5b58\u3055\u308c\u305f\u30d5\u30a9\u30eb\u30c0\u306e\u30d1\u30b9\u3002\n$inputDirPath = preg_replace(&#039;\/\\\/$\/&#039;, &#039;&#039;, $argv&#x5B;1]);\n\n\/\/ \u5909\u63db\u5f8c\u306e\u753b\u50cf\u304c\u4fdd\u5b58\u3055\u308c\u308b\u30d5\u30a9\u30eb\u30c0\u306e\u30d1\u30b9\u3002\n$outputDirPath = preg_replace(&#039;\/\\\/$\/&#039;, &#039;&#039;, $argv&#x5B;2]);\n\n\/\/ \u5909\u63db\u524d\u3068\u5909\u63db\u5f8c\u306e\u753b\u50cf\u306e\u30d1\u30b9\u3092\u53d6\u5f97\u3002\n$inputFilePath = &#x5B;];\n$outputFilePath = &#x5B;];\nforeach (glob($inputDirPath.&#039;\/*.{JPG,jpg,JPEG,jpeg}&#039;, GLOB_BRACE) as $filePath) {\n    $inputFilePath&#x5B;] = $filePath;\n    $outputFilePath&#x5B;] = $outputDirPath.&#039;\/&#039;.pathinfo($filePath, PATHINFO_FILENAME).&#039;.webp&#039;;\n}\n\n\/\/ \u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f\u3002\n$images = &#x5B;];\ntry {\n    foreach ($inputFilePath as $index =&gt; $path) {\n        $images&#x5B;] = imagecreatefromjpeg($path);\n        if ($images&#x5B;$index] === false) {\n            printf(&quot;Error in imagecreatefromjpeg\\n&quot;);\n            return false;\n        }\n    }\n} catch (Throwable $e) {\n    echo $e;\n    return false;\n}\n\n\/\/ \u753b\u50cf\u306e\u7de8\u96c6\u3002\n$changedImages = &#x5B;];\nforeach ($images as $index =&gt; $image) {\n    \/\/ \u6a2a\u5e451000px\u306b\u8a2d\u5b9a\u3002\uff08\u7e26\u5e45\u306f\u6bd4\u7387\u306b\u5fdc\u3058\u3066\u5909\u66f4\u3055\u308c\u308b\uff09\n    $changedImages&#x5B;] = imagescale($image, 1000);\n\n    \/\/ \u6587\u5b57\u8272\u3092\u8a2d\u5b9a\u3002\uff08\u9ed2\uff09\n    $color = imagecolorallocatealpha($changedImages&#x5B;$index], 0x00, 0x00, 0x00, 10);\n\n    \/\/ \u6587\u5b57\u5217\u8ffd\u52a0\u3002\n    $isSuccessStr = imagefttext(\n        $changedImages&#x5B;$index],\n        15,\n        0,\n        30,\n        30,\n        $color,\n        &#039;.\/BIZUDGothic-Regular.ttf&#039;,\n        &#039;\u3042\u3044\u3046\u3048\u304a&#039;\n    );\n\n    if (!$isSuccessStr) {\n        printf(&quot;Error in \\$isSuccessStr\\n&quot;);\n        return false;\n    }\n}\n\n\/\/ \u753b\u50cf\u306e\u51fa\u529b\u3002\nforeach ($changedImages as $index =&gt; $image) {\n    \/\/ 96dpi, \u30af\u30aa\u30ea\u30c6\u30a340 \u3067\u30d5\u30a1\u30a4\u30eb\u51fa\u529b\u3002\n    imagewebp($image, $outputFilePath&#x5B;$index], 40);\n    imagedestroy($image);\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u74b0\u5883 OS\uff1amacOS 14.5 PHP\uff1a8.3.7 \uff08brew\u3092\u5229\u7528\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff09\uff08GD\u3084&#8211;with-freetype\u7b49\u304c\u6709\u52b9\u5316\u3055\u308c\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308b\uff09 GoogleFonts\u7b49\u304b\u3089\u4f7f\u7528\u53ef\u80fd\u306a\u30d5\u30a9\u30f3\u30c8\u3092\u30c0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80],"tags":[81],"class_list":["post-1188","post","type-post","status-publish","format-standard","hentry","category-php","tag-php"],"_links":{"self":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/1188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1188"}],"version-history":[{"count":5,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/1188\/revisions"}],"predecessor-version":[{"id":1196,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/1188\/revisions\/1196"}],"wp:attachment":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}