{"id":3383,"date":"2023-01-05T23:03:07","date_gmt":"2023-01-05T14:03:07","guid":{"rendered":"https:\/\/www.thun-techblog.com\/?p=3383"},"modified":"2023-01-28T22:00:03","modified_gmt":"2023-01-28T13:00:03","slug":"auto-php-gen-img-and-ogp-settings","status":"publish","type":"post","link":"https:\/\/www.thun-techblog.com\/index.php\/blog\/auto-php-gen-img-and-ogp-settings\/","title":{"rendered":"\u30d7\u30e9\u30b0\u30a4\u30f3\u7121\u3057\u3067OGP\u306e\u8a2d\u5b9a\u3068OGP\u7528\u306e\u753b\u50cf\u3092\u81ea\u52d5\u751f\u6210\u3057\u3066\u307f\u308b\u3010WordPress\u3011"},"content":{"rendered":"\n<p>WordPress\u306f\u4f7f\u3044\u3084\u3059\u304f\u81ea\u7531\u5ea6\u304c\u9ad8\u3044\u53cd\u9762\u3001\u81ea\u5206\u3067\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3053\u3068\u304c\u4e00\u5b9a\u6570\u5b58\u5728\u3057\u307e\u3059\u3002\u305d\u306e\u4ee3\u8868\u304cOGP\u306e\u8a2d\u5b9a\u3068\u3082\u3044\u3048\u308b\u3067\u3057\u3087\u3046\u3002\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u306e\u5b9f\u88c5\u3068\u3044\u3046\u306e\u3082\u3042\u308a\u3060\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306f\u5165\u308c\u3059\u304e\u3060\u3068\u91cd\u304f\u306a\u308b\u3001\u3042\u308b\u610f\u5473\u3067\u81ea\u7531\u304c\u5229\u304b\u306a\u3044\u3068\u3044\u3046\u554f\u984c\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>OGP\u306e\u8a2d\u5b9a\u81ea\u4f53\u306f\u7c21\u5358\u3067\u3059\u304c\u3001\u898b\u6804\u3048\u3092\u6c17\u306b\u3057\u3060\u3059\u3068\u6c17\u306b\u306a\u308b\u306e\u304cOGP\u306b\u4f7f\u3046\u753b\u50cf(og:image\u306e\u90e8\u5206)\u3067\u3059\u3002\u3053\u306e\u30c6\u30fc\u30de\u3084\u8a18\u4e8b\u3092\u66f8\u304f\u5074\u306e\u90fd\u5408\u3067\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1\u753b\u50cf\u3092\u8a2d\u5b9a\u3057\u306a\u3044\u3053\u3068\u304c\u5927\u534a\u3060\u3063\u305f\u308a\u3059\u308b\u306e\u3067\u3001OGP\u306b\u5bfe\u5fdc\u3057\u3066\u3082\u56fa\u5b9a\u7684\u306a\u753b\u50cf\u3057\u304b\u51fa\u305b\u306a\u3044\u3068\u3044\u3046\u306e\u304c\u6b20\u70b9\u306b\u306a\u308a\u3084\u3059\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u3053\u3067\u3001\u30bf\u30a4\u30c8\u30eb\u306b\u3042\u308b\u901a\u308a\u3001WordPress\u3067\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u308f\u306a\u3044\u3067OGP\u306e\u8a2d\u5b9a\u3092\u3057\u3064\u3064\u3001\u753b\u50cf\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u65b9\u5411\u3067\u4f5c\u696d\u3092\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n<style>\n.test { width: 320px; height: 100px; }\n@media(min-width: 500px) { .test { width: 468px; height: 60px; } }\n@media(min-width: 800px) { .test { width: 728px; height: 90px; } }\n<\/style>\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-4541970754535576\"\n     crossorigin=\"anonymous\"><\/script>\n<!-- \u3044\u3064\u3082\u306e\u6b63\u65b9\u5f62\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u30eb\u5e83\u544a -->\n<ins class=\"adsbygoogle test\"\n     style=\"display:block\"\n     data-ad-client=\"ca-pub-4541970754535576\"\n     data-ad-slot=\"5487611343\"\n     data-ad-format=\"auto\"\n     data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n<p>OGP\u306e\u8a2d\u5b9a\u306f\u8abf\u3079\u3066\u307f\u308b\u3068WordPress\u306e\u30c6\u30fc\u30de\u30a8\u30c7\u30a3\u30bf\u30fc\u3067\u3067\u304d\u308b\u7a0b\u5ea6\u306b\u306f\u7c21\u5358\u306a\u3088\u3046\u3067\u3059\u3002\u8abf\u3079\u308c\u3070\u3044\u304f\u3089\u3067\u3082\u51fa\u3066\u304d\u307e\u3059\u304c\u3001\u4f8b\u3048\u3070\u3053\u306e\u3088\u3046\u306a\u8a18\u4e8b\u304c\u51fa\u3066\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/296.co.jp\/article\/19031520191205900\">https:\/\/296.co.jp\/article\/19031520191205900<\/a><\/p>\n\n\n\n<p>1\u304b\u3089\u66f8\u3044\u3066\u3082\u826f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u697d\u306b\u8d8a\u3057\u305f\u3053\u3068\u306f\u306a\u3044\u306e\u3067\u4eca\u56de\u306f\u3053\u3053\u3092\u53c2\u8003\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u66f8\u3044\u3066\u3042\u308b\u30b3\u30fc\u30c9\u3092\u30b3\u30d4\u30da\u3057\u521d\u671f\u8a2d\u5b9a\u3092\u3059\u308b\u3060\u3051\u3067\u4e2d\u8eab\u306f\u3055\u3066\u304a\u304dOGP\u306e\u8a2d\u5b9a\u306f\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u3060\u3051\u3067\u3082\u5341\u5206\u898b\u305f\u76ee\u306f\u7acb\u6d3e\u306a\u3082\u306e\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u4f8b\u304c\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"518\" height=\"145\" src=\"https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-221419.jpg\" alt=\"\" class=\"wp-image-3385\" srcset=\"https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-221419.jpg 518w, https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-221419-300x84.jpg 300w\" sizes=\"auto, (max-width: 518px) 100vw, 518px\" \/><figcaption class=\"wp-element-caption\">OGP\u3092\u8a2d\u5b9a\u3057\u3066\u307f\u305f\u4f8b<\/figcaption><\/figure>\n\n\n\n<p>\u3053\u306e\u753b\u50cf\u3092\u898b\u3066\u601d\u3046\u306e\u304c\u3001\u8a18\u4e8b\u306e\u6982\u8981\u304c\u6a2a\u306b\u66f8\u304b\u308c\u3066\u3044\u308b\u3082\u306e\u306e\u3001\u5de6\u306e\u5199\u771f\u306f\u305f\u3060\u306e\u98fe\u308a\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u3001\u60c5\u5831\u304c\u4e00\u5207\u306a\u3044\u3068\u3044\u3046\u70b9\u3067\u3059\u306d\u3002<\/p>\n\n\n\n<p>Twitter\u306e\u5834\u5408\u306f\u3001summary\u3068summary_large_image\u306e\u3069\u3061\u3089\u306e\u30bf\u30b0\u304b\u306b\u3088\u3063\u3066\u8868\u793a\u304c\u5909\u308f\u308a\u307e\u3059\u304c\u3001\u3069\u3061\u3089\u306e\u5834\u5408\u3082\u540c\u3058\u72b6\u614b\u3067\u3059\u3002\u30aa\u30b7\u30e3\u30ec\u306a\u30b5\u30a4\u30c8\u3060\u3068\u6d77\u8fba\u306e\u7dba\u9e97\u306a\u5199\u771f\u3068\u304b\u305d\u3093\u306a\u306e\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u4eba\u304c\u591a\u3044\u3088\u3046\u306b\u601d\u3044\u307e\u3059\u304c\u3001\u60c5\u5831\u306f\u4e00\u5207\u5165\u3063\u3066\u3053\u306a\u3044\u3068\u3044\u3046\u70b9\u3060\u3051\u306f\u5909\u308f\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3092\u306a\u3093\u3068\u304b\u3057\u305f\u3044\u306a\u30fc\u3068\u601d\u3046\u3068\u3001\u30da\u30fc\u30b8\u3054\u3068\u306b\u8868\u793a\u3059\u308b\u753b\u50cf\u3092\u5909\u3048\u308b\u3068\u3044\u3046\u4f5c\u696d\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u3092\u624b\u52d5\u3067\u3084\u308d\u3046\u3068\u601d\u3046\u3068\u3001\u8a18\u4e8b\u3054\u3068\u306b\u753b\u50cf\u3092\u7528\u610f\u3057\u3066\u3001\u305d\u308c\u3092\u8a2d\u5b9a\u3057\u3066\u3068\u9762\u5012\u304c\u5897\u3048\u3066\u3044\u304d\u307e\u3059\u3002\u3057\u304b\u3082\u3001\u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u5727\u8feb\u3057\u305f\u308a\u3001\u30da\u30fc\u30b8\u306b\u753b\u50cf\u304c\u5897\u3048\u308b\u306e\u3067\u50c5\u304b\u3067\u3059\u304c\u901f\u5ea6\u306e\u4f4e\u4e0b\u3092\u62db\u304f\u3068\u3044\u3046\u70b9\u3082\u3044\u305f\u3060\u3051\u307e\u305b\u3093\u306d\u3002<\/p>\n\n\n\n<p>\u3053\u3046\u3044\u3063\u305f\u3053\u3068\u3092\u8003\u616e\u3059\u308b\u3068\u3001\u6587\u5b57\u3092\u3044\u308c\u308c\u3070\u826f\u3044\u306e\u3067\u306f\u3068\u8003\u3048\u307e\u3059\u3002\u6587\u5b57\u3092\u3044\u308c\u308b\u3068\u306a\u308b\u3068\u30d8\u30c3\u30c9\u30ec\u30b9\u30d6\u30e9\u30a6\u30b6\u3068\u304bcanvas API\u3042\u305f\u308a\u4f7f\u3046\u306e\u304b\u306a\u3001\u3068\u3044\u3046\u8003\u3048\u306f\u9593\u9055\u3063\u3066\u3044\u306a\u3044\u3088\u3046\u3067\u3001\u8abf\u3079\u3066\u307f\u308b\u3068\u540c\u3058\u3088\u3046\u306a\u8003\u3048\u306e\u65b9\u304c\u591a\u3044\u3067\u3059\u306d\u3002\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306b\u304b\u306a\u308a\u4f59\u88d5\u304c\u3042\u308b\u306a\u3089\u305d\u308c\u3067\u3082\u826f\u3044\u304b\u306a\u3068\u601d\u3063\u305f\u308a\u3082\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u504f\u898b\u3068\u3057\u3066\u30d8\u30c3\u30c9\u30ec\u30b9\u30d6\u30e9\u30a6\u30b6\u3084\u3089canvas\u306f\u91cd\u3044\u30a4\u30e1\u30fc\u30b8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ed6\u306e\u65b9\u6cd5\u306f\u306a\u3044\u304b\u3068\u63a2\u3057\u3066\u3044\u308b\u3068\u3001\u6c42\u3081\u3066\u3044\u305f\u3053\u3068\u3092\u3084\u3063\u3066\u3044\u308b\u8a18\u4e8b\u3092\u767a\u898b\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/qiita.com\/kiiiiihara\/items\/9b5c9b1d9f55bdf1cd98\">https:\/\/qiita.com\/kiiiiihara\/items\/9b5c9b1d9f55bdf1cd98<\/a><\/p>\n\n\n\n<p>OGP\u306e\u753b\u50cf\u3092\u81ea\u52d5\u3067\u4f5c\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u3084\u3063\u3066\u3044\u308b\u4eba\u306e\u8a18\u4e8b\u3067\u3059\u3002\u7d30\u304b\u3044\u3053\u3068\u306f\u66f8\u3044\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u3072\u3068\u307e\u305a\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3059\u3002\u3053\u306e\u4eba\u306e\u5b9f\u88c5\u3067\u306f\u5206\u306e\u6574\u5f62\u304c\u7121\u304b\u3063\u305f\u306e\u3067\u3001\u305d\u306e\u90e8\u5206\u3092\u8ffd\u52a0\u3067\u5b9f\u88c5\u3057\u307e\u3057\u305f\u3002\u6587\u306e\u6574\u5f62\u306f\u53c2\u8003\u306b\u306a\u308a\u305d\u3046\u306a\u30b3\u30fc\u30c9\u304c\u591a\u304b\u3063\u305f\u306e\u3067\u5408\u3044\u305d\u3046\u306a\u3082\u306e\u3092\u62dd\u501f\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-\u682a\u5f0f\u4f1a\u793e\u30b7\u30fc\u30dd\u30a4\u30f3\u30c8\u30e9\u30dc-\uff5c-\u6d5c\u677e\u306e\u30b7\u30b9\u30c6\u30e0\u30fbrtk-gnss\u958b\u767a wp-block-embed-\u682a\u5f0f\u4f1a\u793e\u30b7\u30fc\u30dd\u30a4\u30f3\u30c8\u30e9\u30dc-\uff5c-\u6d5c\u677e\u306e\u30b7\u30b9\u30c6\u30e0\u30fbrtk-gnss\u958b\u767a\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"nQWGk8kf9A\"><a href=\"https:\/\/cpoint-lab.co.jp\/article\/202104\/19827\/\">\u3010PHP\u3011\u6587\u5b57\u3092\u57cb\u3081\u8fbc\u3080\u753b\u50cf\u3092\u751f\u6210\u3059\u308b\u969b\u3001\u6587\u5b57\u5217\u3092\u4e2d\u592e\u63c3\u3048\u306b\u3057\u305f\u308a\u3001\u6587\u5b57\u5217\u5e45\u306b\u5408\u308f\u305b\u3066\u6298\u308a\u8fd4\u3057\u305f\u308a\u3001\u6587\u5b57\u5217\u5e45\u306b\u5408\u308f\u305b\u3066\u753b\u50cf\u30b5\u30a4\u30ba\u3092\u5909\u3048\u305f\u308a<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;\u3010PHP\u3011\u6587\u5b57\u3092\u57cb\u3081\u8fbc\u3080\u753b\u50cf\u3092\u751f\u6210\u3059\u308b\u969b\u3001\u6587\u5b57\u5217\u3092\u4e2d\u592e\u63c3\u3048\u306b\u3057\u305f\u308a\u3001\u6587\u5b57\u5217\u5e45\u306b\u5408\u308f\u305b\u3066\u6298\u308a\u8fd4\u3057\u305f\u308a\u3001\u6587\u5b57\u5217\u5e45\u306b\u5408\u308f\u305b\u3066\u753b\u50cf\u30b5\u30a4\u30ba\u3092\u5909\u3048\u305f\u308a&#8221; &#8212; \u682a\u5f0f\u4f1a\u793e\u30b7\u30fc\u30dd\u30a4\u30f3\u30c8\u30e9\u30dc \uff5c  \u6d5c\u677e\u306e\u30b7\u30b9\u30c6\u30e0\u30fbRTK-GNSS\u958b\u767a\" src=\"https:\/\/cpoint-lab.co.jp\/article\/202104\/19827\/embed\/#?secret=zBNFoybQh4#?secret=nQWGk8kf9A\" data-secret=\"nQWGk8kf9A\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u3042\u3068\u306f\u3053\u308c\u3060\u3051\u3060\u3068\u307e\u3060\u4e0d\u8db3\u3057\u3066\u3044\u308b\u306e\u304c\u30bb\u30f3\u30bf\u30ea\u30f3\u30b0\u306e\u30b3\u30fc\u30c9\u304c\u6b20\u3051\u3066\u3044\u308b\u3088\u3046\u306a\u306e\u3067\u3001\u9069\u5f53\u306b\u5b9f\u88c5\u3057\u307e\u3057\u305f\u3002\u6570\u30d4\u30af\u30bb\u30eb\u306a\u3089\u305a\u308c\u3066\u3082\u6c17\u306b\u306a\u3089\u306a\u3044\u3060\u308d\u3046\u3068\u3044\u3046\u9069\u5f53\u3055\u304c\u6ef2\u307f\u51fa\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3067\u3001\u51fa\u6765\u4e0a\u304c\u3063\u305f\u30b3\u30fc\u30c9\u304c\u3053\u308c\u3067\u3059\u3002\u9069\u5f53\u306b\u5207\u308a\u8cbc\u308a\u3057\u3059\u304e\u305f\u306e\u3068\u30bb\u30f3\u30bf\u30ea\u30f3\u30b0\u306e\u90e8\u5206\u304c\u5c11\u3057\u3054\u3061\u3083\u3054\u3061\u3083\u3057\u305f\u306e\u3067\u5909\u6570\u304c\u60b2\u60e8\u306a\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u3054\u611b\u656c\u3068\u3044\u3046\u3053\u3068\u3067\u2026<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-file=\"ogpimg.php\" data-lang=\"PHP\"><code>&lt;?php\n\n  $fontSize = 56; \/\/ \u6587\u5b57\u30b5\u30a4\u30ba\n  $fontFamily = &#39;font.ttf&#39;; \/\/ TrueType\u30d5\u30a9\u30f3\u30c8\u3092\u6307\u5b9a\u3059\u308b\n  $MarginX=50;\/\/\u6a2a\u65b9\u5411\u30de\u30fc\u30b8\u30f3\n  $MarginY=50;\/\/\u7e26\u65b9\u5411\u30de\u30fc\u30b8\u30f3\n  $angle=0;\/\/\u6587\u5b57\u3092\u56de\u8ee2\u3055\u305b\u308b\u5834\u5408\u7528\n  $txtX = $fontSize+$MarginX; \/\/ \u6587\u5b57\u306e\u6a2a\u4f4d\u7f6e(\u6587\u5b57\u306e\u5de6\u304c\u57fa\u6e96)\n  $txtY = $fontSize * 2+$MarginY; \/\/ \u6587\u5b57\u306e\u7e26\u4f4d\u7f6e(\u6587\u5b57\u306e\u30d9\u30fc\u30b9\u30e9\u30a4\u30f3\u304c\u57fa\u6e96)\n  $txt = $_GET[&#39;text&#39;]; \/\/ \u30c6\u30ad\u30b9\u30c8\u62fe\u3046\u7528\n\n  $Nx=1200; \/\/\u5143\u753b\u50cf\u306e\u6a2a\u30d4\u30af\u30bb\u30eb\u6570\n  $Ny=630; \/\/\u5143\u753b\u50cf\u306e\u7e26\u30d4\u30af\u30bb\u30eb\u6570\n  $ENx=$Nx-$txtX*2;\/\/\u6709\u52b9\u6a2a\u30d4\u30af\u30bb\u30eb\u6570\n  $ENy=$Ny-$txtY*2;\/\/\u6709\u52b9\u7e26\u30d4\u30af\u30bb\u30eb\u6570\n  $newtxt=imageWordwrap($fontSize, $angle, $fontFamily, $txt, $ENx);\n  $initpos=imagettfbbox($fontSize, $angle,$fontFamily,$newtxt);\n  $BoxHight=$initpos[1]-$initpos[7];\n  $txtln=round($BoxHight\/$fontSize);\n  $step=$fontSize\/2;\n  $centY=$Ny\/2+$MarginY;\n  $initcol=$centY+$fontsize*2;\n\n  $img = imagecreatefrompng(&#39;base.png&#39;); \/\/ \u30c6\u30ad\u30b9\u30c8\u3092\u8f09\u305b\u308b\u753b\u50cf\n  $color = imagecolorallocate($img, 0, 0, 0); \/\/ \u30c6\u30ad\u30b9\u30c8\u306e\u8272\u6307\u5b9a(RGB)\n\n  imagettftext($img, $fontSize, $angle, $txtX,$initcol-$txtln*$step, $color, $fontFamily, $newtxt);\/\/\u521d\u671f\u4f4d\u7f6e\u304b\u3089\u884c\u5206\u3060\u3051\u30b7\u30d5\u30c8\n  \/\/imagestring($img, 5, $txtX , $txtY, $txt, $white);\n\n  header(&#39;Content-Type: image\/png&#39;);\n  imagepng($img);\n  imagedestroy($img);\n\/**\n * \u753b\u50cf\u306e\u5e45\u3067\u6298\u308a\u8fd4\u3057\n * @param  int    $size       \u6587\u5b57\u30b5\u30a4\u30ba\n * @param  int    $angle      \u89d2\u5ea6\n * @param  string $font       \u30d5\u30a9\u30f3\u30c8\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u30d1\u30b9\n * @param  string $text       \u9ad8\u3055\u3068\u5e45\u3092\u77e5\u308a\u305f\u3044\u6587\u5b57\u5217\n * @param  int    $imageWidth \u753b\u50cf\u306e\u5e45\n * @param  string $break      \u6539\u884c\u6587\u5b57\n * @return string\n *\/\nfunction imageWordwrap(\n    int $size,\n    int $angle,\n    string $font,\n    string $text,\n    int $imageWidth,\n    string $break = &quot;\\r\\n&quot;\n): string {\n    \/** @var string[] $cahrs 1\u6587\u5b57\u305a\u3064\u306b\u5206\u89e3\u3002\u7d75\u6587\u5b57\u975e\u5bfe\u5fdc\u3002\u5bfe\u5fdc\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u30d5\u30a9\u30f3\u30c8\u3092\u898b\u3064\u3051\u308b\u5fc5\u8981\u3042\u308a *\/\n    $chars       = mb_str_split($text);\n    $lines       = [];\n    $currentLine = &#39;&#39;;\n    foreach ($chars as $ch) {\n        $wh = getTextSize($size, $angle, $font, $currentLine.$ch);\n        if ($wh[&#39;width&#39;] &gt; $imageWidth) {\n            $lines[]     = $currentLine;\n            $currentLine = $ch;\n        } else {\n            $currentLine .= $ch;\n        }\n    }\n    $lines[] = $currentLine;\n\n    return implode($break, $lines);\n}\n  ?&gt;\n<\/code><\/pre><\/div>\n\n\n\n<p>imagestring\u306f\u65e5\u672c\u8a9e\u3067\u306f\u4f7f\u3048\u306a\u3044\u306e\u3068\u30a8\u30a4\u30ea\u30a2\u30b7\u30f3\u30b0\u304c\u52b9\u3044\u3066\u3044\u306a\u304b\u3063\u305f\u308a\u3068\u4e0d\u81ea\u7531\u306a\u306e\u3067\u4f7f\u3063\u3066\u3044\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u30c7\u30d0\u30c3\u30b0\u306e\u90fd\u5408\u3067\u4f7f\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u6700\u521d\u306f\u753b\u50cf\u3060\u3051\u3057\u304b\u51fa\u3066\u3053\u306a\u304b\u3063\u305f\u306e\u3067\u539f\u56e0\u3092\u63a2\u3063\u305f\u3068\u3053\u308d\u30d5\u30a9\u30f3\u30c8\u306e\u6307\u5b9a\u304c\u304a\u304b\u3057\u304b\u3063\u305f\u306e\u304c\u539f\u56e0\u3060\u3063\u305f\u3068\u3044\u3046\u30aa\u30c1\u3067\u3059\u3002\u3082\u3057\u753b\u50cf\u3060\u3051\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u3088\u3046\u306a\u3089\u4e00\u5ea6\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3092\u5916\u3057\u3066\u307f\u3066\u52d5\u4f5c\u78ba\u8a8d\u3092\u3059\u308b\u3068\u539f\u56e0\u304c\u5207\u308a\u5206\u3051\u308c\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u3069\u3053\u304b\u306e\u53c2\u8003\u30da\u30fc\u30b8\u306b\u66f8\u3044\u3066\u3044\u307e\u3059\u304c\u3001\u5b9f\u88c5\u306e\u90fd\u5408\u3067\u30c7\u30d0\u30c3\u30b0\u304c\u6020\u3044\u306e\u3067\u7dcf\u5f53\u305f\u308a\u3067\u3084\u308b\u306e\u304c\u6700\u77ed\u3068\u3044\u3046\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u69cb\u6210\u3068\u3057\u3066\u306f\u53c2\u8003\u306b\u3057\u305f\u30da\u30fc\u30b8\u3068\u540c\u3058\u69cb\u6210\u3067\u30d5\u30a9\u30f3\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u57fa\u3068\u306a\u308b\u753b\u50cf\u3092\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u653e\u308a\u8fbc\u3093\u3067\u3044\u307e\u3059\u3002\u30ed\u30fc\u30ab\u30eb\u30d1\u30b9\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u3060\u3051\u306a\u306e\u3067\u305d\u3053\u3089\u3078\u3093\u306f\u597d\u304d\u306b\u69cb\u6210\u3057\u305f\u3089\u826f\u3044\u304b\u3068\u3002<\/p>\n\n\n\n<p>\u7c21\u5358\u306b\u3053\u306e\u30b3\u30fc\u30c9\u304c\u4f55\u3092\u3057\u3044\u308b\u306e\u304b\u3092\u66f8\u3044\u3066\u304a\u304f\u3068\u307e\u305a\u4e0b\u306e\u753b\u50cf\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"538\" src=\"https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/ogp_base-1024x538.jpg\" alt=\"\" class=\"wp-image-3387\" srcset=\"https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/ogp_base-1024x538.jpg 1024w, https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/ogp_base-300x158.jpg 300w, https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/ogp_base-768x403.jpg 768w, https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/ogp_base.jpg 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u753b\u50cf<\/figcaption><\/figure>\n\n\n\n<p>\u3053\u306e\u753b\u50cf\u306b\u6587\u5b57\u3092\u306e\u305b\u3066\u3044\u308b\u3068\u3044\u3046\u5f62\u3067\u3059\u304c\u3001\u3053\u306e\u67a0\u5185\u306b\u53ce\u307e\u308b\u3088\u3046\u306b\u6539\u884c\u3059\u308b\u3088\u3046\u306b\u3001\u9577\u3044\u6587\u3092\u6539\u884c\u3057\u3066\u304f\u308c\u308bimageWordwrap\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u305d\u308c\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u5f8c\u306f\u6539\u884c\u3055\u308c\u305f\u6587\u5b57\u5217\u3092\u306e\u305b\u308b\u3060\u3051\u2026\u3067\u306f\u306a\u304f\u3001\u5927\u304d\u3055\u306b\u5fdc\u3058\u3066\u7e26\u65b9\u5411\u306e\u30bb\u30f3\u30bf\u30ea\u30f3\u30b0\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002\u6a2a\u65b9\u5411\u306f\u305f\u3060\u9762\u5012\u3060\u3063\u305f\u306e\u3067\u8f9e\u3081\u307e\u3057\u305f(\u305d\u3093\u306a\u77ed\u3044\u30bf\u30a4\u30c8\u30eb\u4f7f\u308f\u306a\u3044\u3057)\u3002<\/p>\n\n\n\n<p>\u4f7f\u3044\u65b9\u3082\u66f8\u3044\u3066\u3042\u308b\u901a\u308a\u3001URL\u306btext\u5024\u3092\u653e\u308a\u8fbc\u3080\u3060\u3051\u3067\u753b\u50cf\u304c\u5909\u308f\u3063\u3066\u304f\u308c\u307e\u3059\u3002\u4f8b\u3048\u3070\u3053\u306e\u3088\u3046\u306b\u3057\u305f\u3068\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>ogpimg.php?text=\u30a2\u30e1\u30f3\u30dc\u8d64\u3044\u306a\u3042\u3044\u3046\u3048\u304a<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u308c\u3092\u8868\u793a\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"536\" src=\"https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-225023-1024x536.jpg\" alt=\"\" class=\"wp-image-3388\" srcset=\"https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-225023-1024x536.jpg 1024w, https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-225023-300x157.jpg 300w, https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-225023-768x402.jpg 768w, https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-225023.jpg 1195w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">\u4f7f\u3063\u305f\u4f8b<\/figcaption><\/figure>\n\n\n\n<p>\u6587\u5b57\u6570\u3092\u5909\u3048\u3066\u3082\u4e0a\u624b\u304f\u6539\u884c\u3055\u308c\u307e\u3059\u3057\u3001\u30bb\u30f3\u30bf\u30ea\u30f3\u30b0\u3082\u3067\u304d\u307e\u3059\u3057\u3001\u30d5\u30a9\u30f3\u30c8\u30b5\u30a4\u30ba\u3092\u5909\u3048\u3066\u3082\u4e0a\u624b\u304f\u52d5\u304f\u306e\u3067\u6e80\u8db3\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3042\u3068\u306f\u3053\u3044\u3064\u3092og:image\u306b\u4f7f\u3063\u305f\u3089\u76ee\u7684\u901a\u308a\u3001OGP\u306e\u8a2d\u5b9a\u3092\u3057\u3064\u3064\u753b\u50cf\u306e\u81ea\u52d5\u751f\u6210\u304c\u3067\u304d\u307e\u3059\u3002php\u306e\u90e8\u5206\u306f\u30d5\u30eb\u30d1\u30b9\u3067\u8a18\u8ff0\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>content=&quot;https:\/\/example.com\/ogpimg.php?text=&#39;.esc_attr($ogp_ttl).&#39;&quot;<\/code><\/pre><\/div>\n\n\n\n<p>\u3053\u308c\u3092OGP\u306b\u4f7f\u3046\u3088\u3046\u306b\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"385\" src=\"https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-223002.jpg\" alt=\"\" class=\"wp-image-3386\" srcset=\"https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-223002.jpg 525w, https:\/\/www.thun-techblog.com\/wp-content\/uploads\/2023\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2023-01-05-223002-300x220.jpg 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><figcaption class=\"wp-element-caption\">\u81ea\u52d5\u751f\u6210\u3057\u305f\u753b\u50cf\u3092OGP\u3067\u4f7f\u3063\u3066\u307f\u305f<\/figcaption><\/figure>\n\n\n\n<p>\u3053\u308c\u3067\u5171\u6709\u3057\u305f\u3068\u304d\u306e\u898b\u6804\u3048\u304c\u826f\u304f\u306a\u308a\u307e\u3057\u305f(\u5171\u6709\u3059\u308b\u3068\u306f\u8a00\u3063\u3066\u3044\u306a\u3044)\u3002<\/p>\n\n\n<style>\n.test { width: 320px; height: 100px; }\n@media(min-width: 500px) { .test { width: 468px; height: 60px; } }\n@media(min-width: 800px) { .test { width: 728px; height: 90px; } }\n<\/style>\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-4541970754535576\"\n     crossorigin=\"anonymous\"><\/script>\n<!-- \u3044\u3064\u3082\u306e\u6b63\u65b9\u5f62\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u30eb\u5e83\u544a -->\n<ins class=\"adsbygoogle test\"\n     style=\"display:block\"\n     data-ad-client=\"ca-pub-4541970754535576\"\n     data-ad-slot=\"5487611343\"\n     data-ad-format=\"auto\"\n     data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>","protected":false},"excerpt":{"rendered":"<p>WordPress\u306f\u4f7f\u3044\u3084\u3059\u304f\u81ea\u7531\u5ea6\u304c\u9ad8\u3044\u53cd\u9762\u3001\u81ea\u5206\u3067\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3053\u3068\u304c\u4e00\u5b9a\u6570\u5b58\u5728\u3057\u307e\u3059\u3002\u305d\u306e\u4ee3\u8868\u304cOGP\u306e\u8a2d\u5b9a\u3068\u3082\u3044\u3048\u308b\u3067\u3057\u3087\u3046\u3002\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u306e\u5b9f\u88c5\u3068\u3044\u3046\u306e\u3082\u3042\u308a\u3060\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u306f\u5165\u308c\u3059\u304e\u3060\u3068\u91cd\u304f\u306a\u308b&hellip; <a class=\"more-link\" href=\"https:\/\/www.thun-techblog.com\/index.php\/blog\/auto-php-gen-img-and-ogp-settings\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u30d7\u30e9\u30b0\u30a4\u30f3\u7121\u3057\u3067OGP\u306e\u8a2d\u5b9a\u3068OGP\u7528\u306e\u753b\u50cf\u3092\u81ea\u52d5\u751f\u6210\u3057\u3066\u307f\u308b\u3010WordPress\u3011<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,103],"tags":[],"class_list":["post-3383","post","type-post","status-publish","format-standard","hentry","category-linux","category-tool","entry"],"_links":{"self":[{"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=3383"}],"version-history":[{"count":6,"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3383\/revisions"}],"predecessor-version":[{"id":3443,"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3383\/revisions\/3443"}],"wp:attachment":[{"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=3383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=3383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thun-techblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=3383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}