{"id":2479,"date":"2025-03-24T08:47:11","date_gmt":"2025-03-23T23:47:11","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=2479"},"modified":"2025-03-24T08:47:41","modified_gmt":"2025-03-23T23:47:41","slug":"php%e3%81%aeintervention-image%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a%e5%87%a6%e7%90%86%e9%80%9f%e5%ba%a62%e5%80%8d%e3%82%92%e5%ae%9f%e7%8f%be%e3%81%99%e3%82%8b%e3%83%86%e3%82%af","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=2479","title":{"rendered":"PHP\u306eIntervention Image\u5b8c\u5168\u30ac\u30a4\u30c9\uff1a\u51e6\u7406\u901f\u5ea62\u500d\u3092\u5b9f\u73fe\u3059\u308b\u30c6\u30af\u30cb\u30c3\u30af"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">Intervention Image \u3068\u306f\uff1aPHP \u306e\u753b\u50cf\u51e6\u7406\u3092\u9769\u65b0\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">\u5f93\u6765\u306e\u753b\u50cf\u51e6\u7406\u3068\u306e\u6bd4\u8f03\u3067\u5727\u5012\u7684\u306a\u512a\u4f4d\u6027\u3092\u5224\u65ad<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-2\">\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u8ffd\u52a0\u3055\u308c\u305f\u9769\u65b0\u7684\u306a\u6a5f\u80fd<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-3\">Intervention Image\u306e\u57fa\u672c\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u304b\u3089\u5fdc\u7528\u307e\u3067<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-4\">Composer\u3092\u4f7f\u3063\u305f\u6700\u901f\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-5\">Laravel\/Symfony\u3067\u306e\u52b9\u7387\u7684\u306a\u7d71\u5408\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-8\">\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-9\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6700\u5927\u5316\u3059\u308b\u753b\u50cf\u51e6\u7406\u30c6\u30af\u30cb\u30c3\u30af<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-10\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u309250%\u524a\u6e1b\u3059\u308b\u305f\u3081\u306e\u6700\u9069\u5316\u6226\u7565<\/a>      <\/li>      <li>        <a href=\"#i-11\">\u30ad\u30e3\u30c3\u30b7\u30e5\u6a5f\u80fd\u3092\u6d3b\u7528\u3057\u305f\u51e6\u7406\u901f\u5ea6\u306e\u6539\u5584<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-12\">\u30d0\u30c3\u30c1\u51e6\u7406\u306b\u3088\u308b\u5927\u91cf\u753b\u50cf\u306e\u52b9\u7387\u7684\u306a\u51e6\u7406\u65b9\u6cd5<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-13\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-14\">\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u753b\u50cf\u306e\u81ea\u52d5\u751f\u6210\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9<\/a>      <\/li>      <li>        <a href=\"#i-15\">\u753b\u50cf\u30d5\u30a3\u30eb\u30bf\u306e\u4f5c\u6210\u3068\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-16\">WebP \u5f62\u5f0f\u3078\u306e\u81ea\u52d5\u5909\u63db\u306b\u3088\u308b\u6700\u9069\u5316<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-17\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u5b89\u5b9a\u6027\u306e\u78ba\u4fdd<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-18\">\u8106\u5f31\u6027\u3092\u9632\u3050\u305f\u3081\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5<\/a>      <\/li>      <li>        <a href=\"#i-19\">\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-20\">\u5927\u898f\u6a21\u30b7\u30b9\u30c6\u30e0\u3067\u306e\u904b\u7528\u30ce\u30a6\u30cf\u30a6<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-21\">\u6b21\u4e16\u4ee3\u306e\u753b\u50cf\u51e6\u7406\u306b\u5411\u3051\u305f\u767a\u5c55\u7684\u306a\u6d3b\u7528\u65b9\u6cd5<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-22\">AI\u3068\u306e\u9023\u643a\u306b\u3088\u308b\u8a8d\u8b58\u753b\u50cf\u6a5f\u80fd\u306e\u5b9f\u73fe<\/a>      <\/li>      <li>        <a href=\"#i-23\">\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3067\u306e\u6d3b\u7528\u4e8b\u4f8b<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-24\">\u5c06\u6765\u7684\u306a\u62e1\u5f35\u6027\u3092\u8003\u616e\u3057\u305f\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">Intervention Image \u3068\u306f\uff1aPHP \u306e\u753b\u50cf\u51e6\u7406\u3092\u9769\u65b0\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Intervention Image\u306f\u3001PHP\u306b\u3088\u308b\u753b\u50cf\u51e6\u7406\u3092\u5287\u7684\u306b\u7c21\u5358\u5316\u3057\u3001\u9ad8\u901f\u5316\u3059\u308b\u5f37\u529b\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002GD\u30e9\u30a4\u30d6\u30e9\u30ea\u3084Imagick\u3092\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3068\u3057\u3066\u5229\u7528\u3057\u3001\u7d71\u4e00\u7684\u306a\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3067\u76f4\u611f\u7684\u306a\u753b\u50cf\u64cd\u4f5c\u3092\u5b9f\u73fe\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">\u5f93\u6765\u306e\u753b\u50cf\u51e6\u7406\u3068\u306e\u6bd4\u8f03\u3067\u5727\u5012\u7684\u306a\u512a\u4f4d\u6027\u3092\u5224\u65ad<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f93\u6765\u306ePHP\u30cd\u30a4\u30c6\u30a3\u30d6\u306e\u753b\u50cf\u51e6\u7406\u3068\u6bd4\u8f03\u3057\u305f\u969b\u306e Intervention Image \u306e\u4e3b\u306a\u5229\u70b9\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u5f93\u6765\u306ePHP\u306b\u3088\u308b\u753b\u50cf\u30ea\u30b5\u30a4\u30ba\n$source = imagecreatefromjpeg('image.jpg');\n$width = imagesx($source);\n$height = imagesy($source);\n$new_width = 300;\n$new_height = floor($height * ($new_width \/ $width));\n$new_image = imagecreatetruecolor($new_width, $new_height);\nimagecopyresampled($new_image, $source, 0, 0, 0, 0, \n    $new_width, $new_height, $width, $height);\nimagejpeg($new_image, 'resized.jpg', 90);\n\n\/\/ Intervention Image\u306b\u3088\u308b\u540c\u3058\u51e6\u7406\n$img = Image::make('image.jpg');\n$img-&gt;resize(300, null, function ($constraint) {\n    $constraint-&gt;aspectRatio();\n})-&gt;save('resized.jpg', 90);<\/pre>\n\n\n<div id=\"id-e5b47d4e-8fcf-44dc-a1ee-08b98ca2bac2\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6a5f\u80fd\u6bd4\u8f03<\/th><th>\u5f93\u6765\u306ePHP<\/th><th>Intervention Image<\/th><\/tr><\/thead><tbody><tr><td>\u30b3\u30fc\u30c9\u91cf<\/td><td>\u591a\u3044<\/td><td>\u5c11\u306a\u3044<\/td><\/tr><tr><td>\u30e1\u30e2\u30ea\u52b9\u7387<\/td><td>\u4e2d\u7a0b\u5ea6<\/td><td>\u9ad8\u3044<\/td><\/tr><tr><td>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/td><td>\u624b\u52d5\u5b9f\u88c5\u304c\u5fc5\u8981<\/td><td>\u7d44\u307f\u8fbc\u307f\u6e08\u307f<\/td><\/tr><tr><td>\u62e1\u5f35\u6027<\/td><td>\u4f4e\u3044<\/td><td>\u9ad8\u3044<\/td><\/tr><tr><td>\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u7d71\u5408<\/td><td>\u96e3\u3057\u3044<\/td><td>\u5bb9\u6613<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u8ffd\u52a0\u3055\u308c\u305f\u9769\u65b0\u7684\u306a\u6a5f\u80fd<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Intervention Image 3.0\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u9769\u65b0\u7684\u306a\u6a5f\u80fd\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3057\u305f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u975e\u540c\u671f\u51e6\u7406\u30b5\u30dd\u30fc\u30c8<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   \/\/ \u975e\u540c\u671f\u3067\u306e\u753b\u50cf\u51e6\u7406\n   $image-&gt;async()-&gt;resize(800, 600)-&gt;save('output.jpg');<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>WebP\u5bfe\u5fdc\u306e\u5f37\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   \/\/ WebP\u5f62\u5f0f\u3067\u306e\u4fdd\u5b58\u3068\u54c1\u8cea\u6700\u9069\u5316\n   $image-&gt;encode('webp', 75)-&gt;save('image.webp');<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30b9\u30de\u30fc\u30c8\u30af\u30ed\u30c3\u30d4\u30f3\u30b0<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   \/\/ AI\u30d9\u30fc\u30b9\u306e\u91cd\u8981\u90e8\u5206\u691c\u51fa\u306b\u3088\u308b\u30af\u30ed\u30c3\u30d4\u30f3\u30b0\n   $image-&gt;smartCrop(400, 300)-&gt;save('cropped.jpg');<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u308c\u3089\u306e\u6a5f\u80fd\u306b\u3088\u308a\u3001Intervention Image\u306f\u73fe\u4ee3\u306eWeb\u958b\u767a\u306b\u304a\u3051\u308b\u753b\u50cf\u51e6\u7406\u306e\u8981\u4ef6\u3092\u5b8c\u5168\u306b\u30ab\u30d0\u30fc\u3057\u3001\u958b\u767a\u52b9\u7387\u3068\u51e6\u7406\u6027\u80fd\u306e\u4e21\u9762\u3067\u512a\u308c\u305f\u9078\u629e\u80a2\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-3\">Intervention Image\u306e\u57fa\u672c\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u304b\u3089\u5fdc\u7528\u307e\u3067<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">Composer\u3092\u4f7f\u3063\u305f\u6700\u901f\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Intervention Image\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u3001Composer\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u7c21\u5358\u306b\u884c\u3048\u307e\u3059\u3002\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u5fdc\u3058\u3066\u9069\u5207\u306a\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u6700\u65b0\u306e\u5b89\u5b9a\u7248\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\ncomposer require intervention\/image\n\n# \u7279\u5b9a\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff08\u4f8b\uff1a\u30d0\u30fc\u30b8\u30e7\u30f33.0\uff09\ncomposer require intervention\/image:^3.0<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c\u306f\u3001\u5fc5\u8981\u306a\u4f9d\u5b58\u95a2\u4fc2\u3092\u78ba\u8a8d\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ GD\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u78ba\u8a8d\nif (!extension_loaded('gd')) {\n    throw new RuntimeException('GD library is not installed');\n}\n\n\/\/ Imagick\u306e\u78ba\u8a8d\uff08\u30aa\u30d7\u30b7\u30e7\u30f3\uff09\nif (!extension_loaded('imagick')) {\n    echo 'Warning: Imagick extension is not installed. Falling back to GD';\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">Laravel\/Symfony\u3067\u306e\u52b9\u7387\u7684\u306a\u7d71\u5408\u65b9\u6cd5<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-6\">Laravel\u3067\u306e\u7d71\u5408<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Laravel\u3067\u306eIntervention Image\u306e\u8a2d\u5b9a\u306f\u3001\u30b5\u30fc\u30d3\u30b9\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3092\u4f7f\u7528\u3057\u3066\u884c\u3044\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ config\/app.php\n'providers' =&gt; [\n    Intervention\\Image\\ImageServiceProvider::class,\n],\n\n'aliases' =&gt; [\n    'Image' =&gt; Intervention\\Image\\Facades\\Image::class,\n]\n\n\/\/ \u30d5\u30a1\u30b5\u30fc\u30c9\u3092\u4f7f\u7528\u3057\u305f\u4f8b\nuse Image;\n\npublic function store(Request $request)\n{\n    if ($request-&gt;hasFile('image')) {\n        $image = Image::make($request-&gt;file('image'))\n            -&gt;resize(800, null, function ($constraint) {\n                $constraint-&gt;aspectRatio();\n                $constraint-&gt;upsize();\n            })\n            -&gt;save(storage_path('app\/public\/images\/' . time() . '.jpg'));\n    }\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"i-7\">Symfony\u3067\u306e\u7d71\u5408<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Symfony\u3067\u306f\u3001\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u767b\u9332\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># config\/services.yaml\nservices:\n    Intervention\\Image\\ImageManager:\n        arguments:\n            $driver: 'gd' # \u307e\u305f\u306f 'imagick'<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ ImageManager\u306e\u6ce8\u5165\nuse Intervention\\Image\\ImageManager;\n\nclass ImageController\n{\n    private $imageManager;\n\n    public function __construct(ImageManager $imageManager)\n    {\n        $this-&gt;imageManager = $imageManager;\n    }\n\n    public function process()\n    {\n        $image = $this-&gt;imageManager-&gt;make('path\/to\/image.jpg');\n        \/\/ \u753b\u50cf\u51e6\u7406\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">\u57fa\u672c\u7684\u306a\u8a2d\u5b9a\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u52b9\u7387\u7684\u306a\u753b\u50cf\u51e6\u7406\u306e\u305f\u3081\u306e\u63a8\u5968\u8a2d\u5b9a\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ ImageManager\u306e\u8a2d\u5b9a\n$manager = new ImageManager([\n    'driver' =&gt; 'gd',  \/\/ \u307e\u305f\u306f 'imagick'\n    'memory_limit' =&gt; '256M',  \/\/ \u30e1\u30e2\u30ea\u5236\u9650\u306e\u8a2d\u5b9a\n    'temp_dir' =&gt; storage_path('temp'),  \/\/ \u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n]);\n\n\/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u8a2d\u5b9a\u306e\u9069\u7528\n$image = $manager-&gt;make('image.jpg')\n    -&gt;configure([\n        'jpeg_quality' =&gt; 85,  \/\/ JPEG\u54c1\u8cea\n        'png_compression_level' =&gt; 6,  \/\/ PNG\u5727\u7e2e\u30ec\u30d9\u30eb\n        'interlace' =&gt; true,  \/\/ \u30d7\u30ed\u30b0\u30ec\u30c3\u30b7\u30d6\u8868\u793a\u306e\u6709\u52b9\u5316\n    ]);\n\n\/\/ \u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u8a2d\u5b9a\ntry {\n    $image-&gt;resize(800, 600)\n        -&gt;save('output.jpg');\n} catch (Intervention\\Image\\Exception\\NotReadableException $e) {\n    \/\/ \u753b\u50cf\u8aad\u307f\u8fbc\u307f\u30a8\u30e9\u30fc\u306e\u51e6\u7406\n} catch (Intervention\\Image\\Exception\\NotWritableException $e) {\n    \/\/ \u4fdd\u5b58\u30a8\u30e9\u30fc\u306e\u51e6\u7406\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8003\u616e\u3057\u305f\u8a2d\u5b9a\u306e\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n<div id=\"id-99cc9ff2-49a8-4aed-906d-b179d8e7ce4c\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u8a2d\u5b9a\u9805\u76ee<\/th><th>\u63a8\u5968\u5024<\/th><th>\u8aac\u660e<\/th><\/tr><\/thead><tbody><tr><td>\u30e1\u30e2\u30ea\u5236\u9650<\/td><td>256M\u4ee5\u4e0a<\/td><td>\u5927\u304d\u306a\u753b\u50cf\u51e6\u7406\u306b\u5bfe\u5fdc<\/td><\/tr><tr><td>JPEG\u54c1\u8cea<\/td><td>85<\/td><td>\u54c1\u8cea\u3068\u5bb9\u91cf\u306e\u6700\u9069\u306a\u30d0\u30e9\u30f3\u30b9<\/td><\/tr><tr><td>PNG\u5727\u7e2e<\/td><td>6-7<\/td><td>\u51e6\u7406\u6642\u9593\u3068\u5727\u7e2e\u7387\u306e\u30d0\u30e9\u30f3\u30b9<\/td><\/tr><tr><td>\u30ad\u30e3\u30c3\u30b7\u30e5<\/td><td>\u6709\u52b9<\/td><td>\u51e6\u7406\u6e08\u307f\u753b\u50cf\u306e\u30ad\u30e3\u30c3\u30b7\u30e5<\/td><\/tr><tr><td>\u4e00\u6642\u30d5\u30a1\u30a4\u30eb<\/td><td>\u5c02\u7528\u30c7\u30a3\u30ec\u30af\u30c8\u30ea<\/td><td>\u51e6\u7406\u306e\u5b89\u5b9a\u6027\u5411\u4e0a<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">\u3053\u308c\u3089\u306e\u8a2d\u5b9a\u3092\u9069\u5207\u306b\u884c\u3046\u3053\u3068\u3067\u3001\u5b89\u5b9a\u3057\u305f\u753b\u50cf\u51e6\u7406\u74b0\u5883\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-9\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6700\u5927\u5316\u3059\u308b\u753b\u50cf\u51e6\u7406\u30c6\u30af\u30cb\u30c3\u30af<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u309250%\u524a\u6e1b\u3059\u308b\u305f\u3081\u306e\u6700\u9069\u5316\u6226\u7565<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Intervention Image\u306e\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u52b9\u7387\u7684\u306b\u7ba1\u7406\u3059\u308b\u305f\u3081\u306e\u4e3b\u8981\u306a\u6226\u7565\u3092\u7d39\u4ecb\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u6700\u9069\u5316\u3057\u305f\u753b\u50cf\u51e6\u7406\u306e\u4f8b\nuse Intervention\\Image\\ImageManager;\n\nclass OptimizedImageProcessor\n{\n    private $manager;\n    private $maxSize = 2048; \/\/ \u6700\u5927\u753b\u50cf\u30b5\u30a4\u30ba\n\n    public function __construct()\n    {\n        $this-&gt;manager = new ImageManager([\n            'driver' =&gt; extension_loaded('imagick') ? 'imagick' : 'gd'\n        ]);\n    }\n\n    public function processImage($inputPath, $outputPath)\n    {\n        \/\/ 1. \u753b\u50cf\u60c5\u5831\u306e\u4e8b\u524d\u30c1\u30a7\u30c3\u30af\n        $imageInfo = getimagesize($inputPath);\n        $originalMemory = memory_get_usage();\n\n        try {\n            \/\/ 2. \u5fc5\u8981\u306b\u5fdc\u3058\u3066\u6bb5\u968e\u7684\u306a\u30ea\u30b5\u30a4\u30ba\n            $image = $this-&gt;manager-&gt;make($inputPath);\n\n            if (max($imageInfo[0], $imageInfo[1]) &gt; $this-&gt;maxSize) {\n                $image-&gt;resize($this-&gt;maxSize, $this-&gt;maxSize, function ($constraint) {\n                    $constraint-&gt;aspectRatio();\n                    $constraint-&gt;upsize();\n                });\n            }\n\n            \/\/ 3. \u4e0d\u8981\u306aEXIF\u30c7\u30fc\u30bf\u306e\u524a\u9664\n            $image-&gt;strip();\n\n            \/\/ 4. \u6700\u9069\u5316\u3057\u3066\u4fdd\u5b58\n            $image-&gt;save($outputPath, 85);\n\n            \/\/ 5. \u30e1\u30e2\u30ea\u89e3\u653e\n            $image-&gt;destroy();\n\n            return [\n                'memory_used' =&gt; memory_get_usage() - $originalMemory,\n                'success' =&gt; true\n            ];\n        } catch (\\Exception $e) {\n            return [\n                'error' =&gt; $e-&gt;getMessage(),\n                'success' =&gt; false\n            ];\n        }\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u524a\u6e1b\u52b9\u679c\uff1a<\/p>\n\n\n<div id=\"id-6340170c-797a-4ded-9910-3f5c2ac93ea4\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6700\u9069\u5316\u624b\u6cd5<\/th><th>\u30e1\u30e2\u30ea\u524a\u6e1b\u7387<\/th><th>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3078\u306e\u5f71\u97ff<\/th><\/tr><\/thead><tbody><tr><td>\u6bb5\u968e\u7684\u30ea\u30b5\u30a4\u30ba<\/td><td>\u7d0430%<\/td><td>\u51e6\u7406\u6642\u9593+10%<\/td><\/tr><tr><td>EXIF\u30c7\u30fc\u30bf\u524a\u9664<\/td><td>\u7d0410%<\/td><td>\u5f71\u97ff\u306a\u3057<\/td><\/tr><tr><td>\u9069\u5207\u306a\u30c9\u30e9\u30a4\u30d0\u30fc\u9078\u629e<\/td><td>\u7d0415%<\/td><td>\u51e6\u7406\u6642\u9593-20%<\/td><\/tr><tr><td>\u30e1\u30e2\u30ea\u89e3\u653e\u306e\u5fb9\u5e95<\/td><td>\u7d045%<\/td><td>\u5f71\u97ff\u306a\u3057<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">\u30ad\u30e3\u30c3\u30b7\u30e5\u6a5f\u80fd\u3092\u6d3b\u7528\u3057\u305f\u51e6\u7406\u901f\u5ea6\u306e\u6539\u5584<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u753b\u50cf\u51e6\u7406\u7d50\u679c\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CachedImageProcessor\n{\n    private $cacheDir;\n    private $manager;\n\n    public function __construct($cacheDir)\n    {\n        $this-&gt;cacheDir = $cacheDir;\n        $this-&gt;manager = new ImageManager();\n    }\n\n    public function processWithCache($sourcePath, $operations)\n    {\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30ad\u30fc\u306e\u751f\u6210\n        $cacheKey = md5($sourcePath . serialize($operations));\n        $cachePath = $this-&gt;cacheDir . '\/' . $cacheKey . '.jpg';\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30c1\u30a7\u30c3\u30af\n        if (file_exists($cachePath)) {\n            return $cachePath;\n        }\n\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u306a\u3044\u5834\u5408\u306f\u51e6\u7406\u3092\u5b9f\u884c\n        $image = $this-&gt;manager-&gt;make($sourcePath);\n\n        foreach ($operations as $operation) {\n            $method = $operation['method'];\n            $params = $operation['params'];\n            $image-&gt;$method(...$params);\n        }\n\n        $image-&gt;save($cachePath);\n        return $cachePath;\n    }\n\n    \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\n    public function cleanupCache($maxAge = 86400)\n    {\n        $files = glob($this-&gt;cacheDir . '\/*');\n        foreach ($files as $file) {\n            if (time() - filemtime($file) &gt; $maxAge) {\n                unlink($file);\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u30d0\u30c3\u30c1\u51e6\u7406\u306b\u3088\u308b\u5927\u91cf\u753b\u50cf\u306e\u52b9\u7387\u7684\u306a\u51e6\u7406\u65b9\u6cd5<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5927\u91cf\u306e\u753b\u50cf\u3092\u52b9\u7387\u7684\u306b\u51e6\u7406\u3059\u308b\u305f\u3081\u306e\u30d0\u30c3\u30c1\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class BatchImageProcessor\n{\n    private $manager;\n    private $concurrency;\n    private $processedCount = 0;\n\n    public function __construct($concurrency = 5)\n    {\n        $this-&gt;manager = new ImageManager();\n        $this-&gt;concurrency = $concurrency;\n    }\n\n    public function processBatch(array $images, callable $callback)\n    {\n        $chunks = array_chunk($images, $this-&gt;concurrency);\n\n        foreach ($chunks as $chunk) {\n            $processes = [];\n\n            foreach ($chunk as $image) {\n                $processes[] = $this-&gt;processAsync($image);\n            }\n\n            \/\/ \u51e6\u7406\u5b8c\u4e86\u3092\u5f85\u6a5f\n            foreach ($processes as $process) {\n                $result = $process-&gt;wait();\n                $callback($result);\n                $this-&gt;processedCount++;\n            }\n\n            \/\/ \u30e1\u30e2\u30ea\u89e3\u653e\n            gc_collect_cycles();\n        }\n\n        return $this-&gt;processedCount;\n    }\n\n    private function processAsync($imagePath)\n    {\n        return new Promise(function ($resolve, $reject) use ($imagePath) {\n            try {\n                $image = $this-&gt;manager-&gt;make($imagePath);\n                \/\/ \u753b\u50cf\u51e6\u7406\u64cd\u4f5c\n                $result = [\n                    'path' =&gt; $imagePath,\n                    'success' =&gt; true\n                ];\n                $resolve($result);\n            } catch (\\Exception $e) {\n                $reject($e);\n            }\n        });\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$processor = new BatchImageProcessor(3);\n$images = glob('input\/*.jpg');\n\n$processor-&gt;processBatch($images, function($result) {\n    echo \"Processed: \" . $result['path'] . \"\\n\";\n});<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6539\u5584\u306e\u305f\u3081\u306e\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30e1\u30e2\u30ea\u7ba1\u7406<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5927\u304d\u306a\u753b\u50cf\u306f\u6bb5\u968e\u7684\u306b\u30ea\u30b5\u30a4\u30ba<\/li>\n\n\n\n<li>\u51e6\u7406\u5f8c\u306e\u30e1\u30e2\u30ea\u89e3\u653e\u3092\u5fb9\u5e95<\/li>\n\n\n\n<li>\u30ac\u30d9\u30fc\u30b8\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u9069\u5207\u306a\u5b9f\u884c<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u51e6\u7406\u7d50\u679c\u306e\u6c38\u7d9a\u5316<\/li>\n\n\n\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u6709\u52b9\u671f\u9650\u7ba1\u7406<\/li>\n\n\n\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u306e\u81ea\u52d5\u5316<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d0\u30c3\u30c1\u51e6\u7406\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9069\u5207\u306a\u540c\u6642\u5b9f\u884c\u6570\u306e\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u5b9f\u88c5<\/li>\n\n\n\n<li>\u9032\u6357\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u6a5f\u80fd<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u308c\u3089\u306e\u6700\u9069\u5316\u3092\u9069\u5207\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3067\u3001\u51e6\u7406\u901f\u5ea6\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u306a\u304c\u3089\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u6291\u5236\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-13\">\u5b9f\u8df5\u7684\u306a\u30e6\u30fc\u30b9\u30b1\u30fc\u30b9\u3068\u5b9f\u88c5\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u753b\u50cf\u306e\u81ea\u52d5\u751f\u6210\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u7bc9<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u30e2\u30c0\u30f3\u306aWeb\u30b5\u30a4\u30c8\u306b\u4e0d\u53ef\u6b20\u306a\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u753b\u50cf\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u30b7\u30b9\u30c6\u30e0\u3092\u5b9f\u88c5\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ResponsiveImageGenerator\n{\n    private $manager;\n    private $breakpoints;\n\n    public function __construct()\n    {\n        $this-&gt;manager = new ImageManager(['driver' =&gt; 'gd']);\n        $this-&gt;breakpoints = [\n            'sm' =&gt; 640,\n            'md' =&gt; 768,\n            'lg' =&gt; 1024,\n            'xl' =&gt; 1280,\n            '2xl' =&gt; 1536\n        ];\n    }\n\n    public function generateResponsiveSet($sourcePath, $outputDir)\n    {\n        $sourceImage = $this-&gt;manager-&gt;make($sourcePath);\n        $results = [];\n\n        foreach ($this-&gt;breakpoints as $name =&gt; $width) {\n            $resized = $sourceImage-&gt;clone()\n                -&gt;resize($width, null, function ($constraint) {\n                    $constraint-&gt;aspectRatio();\n                    $constraint-&gt;upsize();\n                });\n\n            \/\/ \u753b\u50cf\u306e\u6700\u9069\u5316\n            $outputPath = sprintf(\n                '%s\/%s-%s.%s',\n                $outputDir,\n                pathinfo($sourcePath, PATHINFO_FILENAME),\n                $name,\n                'webp'\n            );\n\n            $resized-&gt;encode('webp', 80)-&gt;save($outputPath);\n            $results[$name] = $outputPath;\n        }\n\n        \/\/ srcset\u7528\u306eHTML\u751f\u6210\n        $srcset = array_map(function ($path, $width) {\n            return sprintf('%s %dw', $path, $width);\n        }, $results, $this-&gt;breakpoints);\n\n        return [\n            'paths' =&gt; $results,\n            'srcset' =&gt; implode(', ', $srcset)\n        ];\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$generator = new ResponsiveImageGenerator();\n$result = $generator-&gt;generateResponsiveSet(\n    'original.jpg',\n    'public\/images'\n);\n\necho \"&lt;img src='{$result['paths']['md']}' \n    srcset='{$result['srcset']}' \n    sizes='(max-width: 768px) 100vw, 768px'&gt;\";<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-15\">\u753b\u50cf\u30d5\u30a3\u30eb\u30bf\u306e\u4f5c\u6210\u3068\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u65b9\u6cd5<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u72ec\u81ea\u306e\u753b\u50cf\u30d5\u30a3\u30eb\u30bf\u3092\u4f5c\u6210\u3057\u3001\u65e2\u5b58\u306e\u30d5\u30a3\u30eb\u30bf\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class CustomFilters\n{\n    public static function register($manager)\n    {\n        \/\/ \u30d3\u30f3\u30c6\u30fc\u30b8\u30d5\u30a3\u30eb\u30bf\n        $manager-&gt;filter('vintage', function ($image) {\n            return $image-&gt;brightness(-10)\n                -&gt;contrast(10)\n                -&gt;colorize(30, 20, -10)\n                -&gt;gamma(1.2);\n        });\n\n        \/\/ HDR\u30a8\u30d5\u30a7\u30af\u30c8\n        $manager-&gt;filter('hdr', function ($image) {\n            return $image-&gt;contrast(10)\n                -&gt;sharpen(15)\n                -&gt;brightness(5)\n                -&gt;colorize(-5, 0, 5);\n        });\n\n        \/\/ \u30ab\u30b9\u30bf\u30e0\u30a6\u30a9\u30fc\u30bf\u30fc\u30de\u30fc\u30af\n        $manager-&gt;filter('watermark', function ($image) use ($manager) {\n            $watermark = $manager-&gt;make('watermark.png')\n                -&gt;resize($image-&gt;width() \/ 4, null, function ($constraint) {\n                    $constraint-&gt;aspectRatio();\n                });\n\n            return $image-&gt;insert(\n                $watermark,\n                'bottom-right',\n                10,\n                10\n            );\n        });\n    }\n\n    \/\/ \u30d5\u30a3\u30eb\u30bf\u30c1\u30a7\u30fc\u30f3\u306e\u5b9f\u88c5\n    public static function applyFilterChain($image, array $filters)\n    {\n        foreach ($filters as $filter =&gt; $options) {\n            if (is_callable([$image, $filter])) {\n                $image = $image-&gt;$filter(...$options);\n            }\n        }\n        return $image;\n    }\n}\n\n\/\/ \u30d5\u30a3\u30eb\u30bf\u306e\u4f7f\u7528\u4f8b\n$image = Image::make('input.jpg');\nCustomFilters::register($image-&gt;getManager());\n\n\/\/ \u30d5\u30a3\u30eb\u30bf\u30c1\u30a7\u30fc\u30f3\u306e\u9069\u7528\n$filterChain = [\n    'vintage' =&gt; [],\n    'brightness' =&gt; [-5],\n    'watermark' =&gt; []\n];\n\n$processedImage = CustomFilters::applyFilterChain($image, $filterChain)\n    -&gt;save('output.jpg');<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">WebP \u5f62\u5f0f\u3078\u306e\u81ea\u52d5\u5909\u63db\u306b\u3088\u308b\u6700\u9069\u5316<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">WebP\u5f62\u5f0f\u3078\u306e\u52b9\u7387\u7684\u306a\u5909\u63db\u3068\u6700\u9069\u5316\u3092\u884c\u3046\u30b7\u30b9\u30c6\u30e0\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class WebPConverter\n{\n    private $manager;\n    private $quality;\n    private $useProgressive;\n\n    public function __construct($quality = 80, $useProgressive = true)\n    {\n        $this-&gt;manager = new ImageManager();\n        $this-&gt;quality = $quality;\n        $this-&gt;useProgressive = $useProgressive;\n    }\n\n    public function convertToWebP($sourcePath, $outputDir = null)\n    {\n        if (!$outputDir) {\n            $outputDir = dirname($sourcePath);\n        }\n\n        $image = $this-&gt;manager-&gt;make($sourcePath);\n        $filename = pathinfo($sourcePath, PATHINFO_FILENAME);\n        $outputPath = $outputDir . '\/' . $filename . '.webp';\n\n        \/\/ \u753b\u50cf\u306e\u6700\u9069\u5316\u3068WebP\u5909\u63db\n        if ($this-&gt;useProgressive) {\n            $image-&gt;interlace(true);\n        }\n\n        \/\/ \u5143\u753b\u50cf\u306e\u30e1\u30bf\u30c7\u30fc\u30bf\u3092\u4fdd\u6301\u3059\u308b\u304b\u30c1\u30a7\u30c3\u30af\n        $keepMetadata = $this-&gt;shouldKeepMetadata($sourcePath);\n        if (!$keepMetadata) {\n            $image-&gt;strip();\n        }\n\n        \/\/ WebP\u3068\u3057\u3066\u4fdd\u5b58\n        $image-&gt;encode('webp', $this-&gt;quality)-&gt;save($outputPath);\n\n        return [\n            'original_size' =&gt; filesize($sourcePath),\n            'webp_size' =&gt; filesize($outputPath),\n            'compression_ratio' =&gt; round(\n                (1 - filesize($outputPath) \/ filesize($sourcePath)) * 100,\n                2\n            ),\n            'path' =&gt; $outputPath\n        ];\n    }\n\n    private function shouldKeepMetadata($sourcePath)\n    {\n        \/\/ \u5199\u771f\u306e\u5834\u5408\u306fEXIF\u60c5\u5831\u3092\u4fdd\u6301\n        $mime = mime_content_type($sourcePath);\n        return in_array($mime, ['image\/jpeg', 'image\/tiff']);\n    }\n\n    \/\/ \u30d0\u30c3\u30c1\u5909\u63db\u306e\u5b9f\u88c5\n    public function convertDirectory($sourceDir, $outputDir = null)\n    {\n        $files = glob($sourceDir . '\/*.{jpg,jpeg,png}', GLOB_BRACE);\n        $results = [];\n\n        foreach ($files as $file) {\n            try {\n                $results[] = $this-&gt;convertToWebP($file, $outputDir);\n            } catch (\\Exception $e) {\n                $results[] = [\n                    'error' =&gt; $e-&gt;getMessage(),\n                    'path' =&gt; $file\n                ];\n            }\n        }\n\n        return $results;\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$converter = new WebPConverter(85, true);\n\n\/\/ \u5358\u4e00\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u63db\n$result = $converter-&gt;convertToWebP('image.jpg');\nprintf(\n    \"\u5727\u7e2e\u7387: %s%% (\u5143\u30b5\u30a4\u30ba: %s bytes, \u5909\u63db\u5f8c: %s bytes)\\n\",\n    $result['compression_ratio'],\n    $result['original_size'],\n    $result['webp_size']\n);\n\n\/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4e00\u62ec\u5909\u63db\n$results = $converter-&gt;convertDirectory('images\/original', 'images\/webp');<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5404\u5b9f\u88c5\u306b\u304a\u3051\u308b\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u753b\u50cf\u751f\u6210<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9069\u5207\u306a\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u306e\u8a2d\u5b9a<\/li>\n\n\n\n<li>\u753b\u8cea\u3068\u5bb9\u91cf\u306e\u30d0\u30e9\u30f3\u30b9\u8abf\u6574<\/li>\n\n\n\n<li>\u52b9\u7387\u7684\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30eb\u30bf<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e2\u30b8\u30e5\u30fc\u30eb\u6027\u306e\u9ad8\u3044\u8a2d\u8a08<\/li>\n\n\n\n<li>\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u6027<\/li>\n\n\n\n<li>\u30d5\u30a3\u30eb\u30bf\u30c1\u30a7\u30fc\u30f3\u306e\u67d4\u8edf\u306a\u7d44\u307f\u5408\u308f\u305b<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>WebP\u5909\u63db<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u9069\u5207\u306a\u51e6\u7406<\/li>\n\n\n\n<li>\u30d7\u30ed\u30b0\u30ec\u30c3\u30b7\u30d6\u8868\u793a\u306e\u6700\u9069\u5316<\/li>\n\n\n\n<li>\u30d0\u30c3\u30c1\u51e6\u7406\u306e\u52b9\u7387\u5316<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u308c\u3089\u306e\u5b9f\u88c5\u4f8b\u306f\u3001\u5b9f\u969b\u306e\u958b\u767a\u73fe\u5834\u3067\u3059\u3050\u306b\u6d3b\u7528\u3067\u304d\u308b\u5f62\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-17\">\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u5b89\u5b9a\u6027\u306e\u78ba\u4fdd<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u8106\u5f31\u6027\u3092\u9632\u3050\u305f\u3081\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u753b\u50cf\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u78ba\u4fdd\u3059\u308b\u305f\u3081\u306e\u5305\u62ec\u7684\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class SecureImageValidator\n{\n    private $allowedMimes = [\n        'image\/jpeg',\n        'image\/png',\n        'image\/gif',\n        'image\/webp'\n    ];\n\n    private $maxFileSize = 10485760; \/\/ 10MB\n    private $maxDimensions = [\n        'width' =&gt; 5000,\n        'height' =&gt; 5000\n    ];\n\n    public function validate($file)\n    {\n        $errors = [];\n\n        try {\n            \/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u57fa\u672c\u30c1\u30a7\u30c3\u30af\n            if (!$this-&gt;validateBasics($file)) {\n                throw new \\Exception('Basic file validation failed');\n            }\n\n            \/\/ MIME\u30bf\u30a4\u30d7\u306e\u8a73\u7d30\u30c1\u30a7\u30c3\u30af\n            if (!$this-&gt;validateMimeType($file['tmp_name'])) {\n                throw new \\Exception('Invalid file type');\n            }\n\n            \/\/ \u753b\u50cf\u306e\u69cb\u9020\u30c1\u30a7\u30c3\u30af\n            if (!$this-&gt;validateImageStructure($file['tmp_name'])) {\n                throw new \\Exception('Invalid image structure');\n            }\n\n            \/\/ \u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u30b5\u30cb\u30bf\u30a4\u30ba\n            $this-&gt;sanitizeMetadata($file['tmp_name']);\n\n            return [\n                'success' =&gt; true,\n                'validated_path' =&gt; $file['tmp_name']\n            ];\n\n        } catch (\\Exception $e) {\n            return [\n                'success' =&gt; false,\n                'error' =&gt; $e-&gt;getMessage()\n            ];\n        }\n    }\n\n    private function validateBasics($file)\n    {\n        \/\/ \u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u306e\u30c1\u30a7\u30c3\u30af\n        if ($file['size'] &gt; $this-&gt;maxFileSize) {\n            throw new \\Exception('File size exceeds limit');\n        }\n\n        \/\/ \u57fa\u672c\u7684\u306aMIME\u30bf\u30a4\u30d7\u30c1\u30a7\u30c3\u30af\n        if (!in_array($file['type'], $this-&gt;allowedMimes)) {\n            throw new \\Exception('File type not allowed');\n        }\n\n        return true;\n    }\n\n    private function validateMimeType($filePath)\n    {\n        \/\/ fileinfo\u62e1\u5f35\u3092\u4f7f\u7528\u3057\u305f\u8a73\u7d30\u306aMIME\u30c1\u30a7\u30c3\u30af\n        $finfo = finfo_open(FILEINFO_MIME_TYPE);\n        $mimeType = finfo_file($finfo, $filePath);\n        finfo_close($finfo);\n\n        return in_array($mimeType, $this-&gt;allowedMimes);\n    }\n\n    private function validateImageStructure($filePath)\n    {\n        $imageInfo = getimagesize($filePath);\n\n        if ($imageInfo === false) {\n            return false;\n        }\n\n        \/\/ \u753b\u50cf\u30b5\u30a4\u30ba\u306e\u691c\u8a3c\n        if ($imageInfo[0] &gt; $this-&gt;maxDimensions['width'] ||\n            $imageInfo[1] &gt; $this-&gt;maxDimensions['height']) {\n            return false;\n        }\n\n        return true;\n    }\n\n    private function sanitizeMetadata($filePath)\n    {\n        $image = Image::make($filePath);\n        $image-&gt;strip(); \/\/ \u5168\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u524a\u9664\n        $image-&gt;save($filePath);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-19\">\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5805\u7262\u306a\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ImageProcessingErrorHandler\n{\n    private $logger;\n    private $notifier;\n\n    public function __construct($logger, $notifier = null)\n    {\n        $this-&gt;logger = $logger;\n        $this-&gt;notifier = $notifier;\n    }\n\n    public function handle(\\Throwable $error, $context = [])\n    {\n        \/\/ \u30a8\u30e9\u30fc\u306e\u91cd\u8981\u5ea6\u5224\u5b9a\n        $severity = $this-&gt;determineSeverity($error);\n\n        \/\/ \u30a8\u30e9\u30fc\u30ed\u30b0\u306e\u8a18\u9332\n        $this-&gt;logError($error, $severity, $context);\n\n        \/\/ \u6df1\u523b\u306a\u30a8\u30e9\u30fc\u306e\u5834\u5408\u306f\u901a\u77e5\n        if ($severity &gt;= 3 &amp;&amp; $this-&gt;notifier) {\n            $this-&gt;notifier-&gt;send([\n                'error' =&gt; $error-&gt;getMessage(),\n                'severity' =&gt; $severity,\n                'context' =&gt; $context\n            ]);\n        }\n\n        \/\/ \u30e6\u30fc\u30b6\u30fc\u30d5\u30ec\u30f3\u30c9\u30ea\u30fc\u306a\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u751f\u6210\n        return $this-&gt;generateUserMessage($error, $severity);\n    }\n\n    private function determineSeverity(\\Throwable $error)\n    {\n        if ($error instanceof \\OutOfMemoryError) {\n            return 4; \/\/ \u30af\u30ea\u30c6\u30a3\u30ab\u30eb\n        }\n        if ($error instanceof \\InvalidArgumentException) {\n            return 2; \/\/ \u8b66\u544a\n        }\n        return 3; \/\/ \u30a8\u30e9\u30fc\n    }\n\n    private function logError(\\Throwable $error, $severity, $context)\n    {\n        $logData = [\n            'message' =&gt; $error-&gt;getMessage(),\n            'code' =&gt; $error-&gt;getCode(),\n            'file' =&gt; $error-&gt;getFile(),\n            'line' =&gt; $error-&gt;getLine(),\n            'severity' =&gt; $severity,\n            'context' =&gt; $context,\n            'timestamp' =&gt; date('Y-m-d H:i:s')\n        ];\n\n        $this-&gt;logger-&gt;log($severity, json_encode($logData));\n    }\n\n    private function generateUserMessage(\\Throwable $error, $severity)\n    {\n        $messages = [\n            1 =&gt; '\u51e6\u7406\u3092\u5b8c\u4e86\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002',\n            2 =&gt; '\u753b\u50cf\u306e\u51e6\u7406\u4e2d\u306b\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002',\n            3 =&gt; '\u30b7\u30b9\u30c6\u30e0\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002',\n            4 =&gt; '\u6df1\u523b\u306a\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002'\n        ];\n\n        return [\n            'message' =&gt; $messages[$severity] ?? '\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002',\n            'error_code' =&gt; $error-&gt;getCode(),\n            'severity' =&gt; $severity\n        ];\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">\u5927\u898f\u6a21\u30b7\u30b9\u30c6\u30e0\u3067\u306e\u904b\u7528\u30ce\u30a6\u30cf\u30a6<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5927\u898f\u6a21\u30b7\u30b9\u30c6\u30e0\u3067\u306e\u5b89\u5b9a\u904b\u7528\u306e\u305f\u3081\u306e\u5b9f\u88c5\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ImageProcessingSystem\n{\n    private $validator;\n    private $errorHandler;\n    private $metrics;\n    private $cache;\n\n    public function __construct($validator, $errorHandler, $metrics, $cache)\n    {\n        $this-&gt;validator = $validator;\n        $this-&gt;errorHandler = $errorHandler;\n        $this-&gt;metrics = $metrics;\n        $this-&gt;cache = $cache;\n    }\n\n    public function processImage($file, $operations)\n    {\n        $startTime = microtime(true);\n\n        try {\n            \/\/ \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\n            $validationResult = $this-&gt;validator-&gt;validate($file);\n            if (!$validationResult['success']) {\n                throw new \\Exception($validationResult['error']);\n            }\n\n            \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30c1\u30a7\u30c3\u30af\n            $cacheKey = $this-&gt;generateCacheKey($file, $operations);\n            if ($cachedResult = $this-&gt;cache-&gt;get($cacheKey)) {\n                return $cachedResult;\n            }\n\n            \/\/ \u753b\u50cf\u51e6\u7406\n            $result = $this-&gt;executeOperations($file, $operations);\n\n            \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u4fdd\u5b58\n            $this-&gt;cache-&gt;set($cacheKey, $result);\n\n            \/\/ \u30e1\u30c8\u30ea\u30af\u30b9\u8a18\u9332\n            $this-&gt;recordMetrics($startTime, true);\n\n            return $result;\n\n        } catch (\\Throwable $error) {\n            \/\/ \u30a8\u30e9\u30fc\u51e6\u7406\n            $this-&gt;recordMetrics($startTime, false);\n            return $this-&gt;errorHandler-&gt;handle($error, [\n                'file' =&gt; $file,\n                'operations' =&gt; $operations\n            ]);\n        }\n    }\n\n    private function generateCacheKey($file, $operations)\n    {\n        return md5(json_encode([\n            'path' =&gt; $file['tmp_name'],\n            'size' =&gt; $file['size'],\n            'operations' =&gt; $operations\n        ]));\n    }\n\n    private function executeOperations($file, $operations)\n    {\n        $image = Image::make($file['tmp_name']);\n\n        foreach ($operations as $operation) {\n            $method = $operation['method'];\n            $params = $operation['params'] ?? [];\n\n            if (!method_exists($image, $method)) {\n                throw new \\InvalidArgumentException(\n                    \"Invalid operation: {$method}\"\n                );\n            }\n\n            $image = $image-&gt;$method(...$params);\n        }\n\n        return $image;\n    }\n\n    private function recordMetrics($startTime, $success)\n    {\n        $duration = microtime(true) - $startTime;\n        $memory = memory_get_peak_usage(true);\n\n        $this-&gt;metrics-&gt;record([\n            'duration' =&gt; $duration,\n            'memory' =&gt; $memory,\n            'success' =&gt; $success,\n            'timestamp' =&gt; time()\n        ]);\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u904b\u7528\u306b\u304a\u3051\u308b\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u7b56<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5165\u529b\u5024\u306e\u53b3\u5bc6\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/li>\n\n\n\n<li>\u30e1\u30bf\u30c7\u30fc\u30bf\u306e\u9069\u5207\u306a\u51e6\u7406<\/li>\n\n\n\n<li>\u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u306e\u8a73\u7d30\u30c1\u30a7\u30c3\u30af<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6bb5\u968e\u7684\u306a\u30a8\u30e9\u30fc\u91cd\u8981\u5ea6\u5224\u5b9a<\/li>\n\n\n\n<li>\u9069\u5207\u306a\u30ed\u30b0\u8a18\u9332<\/li>\n\n\n\n<li>\u30e6\u30fc\u30b6\u30fc\u30d5\u30ec\u30f3\u30c9\u30ea\u30fc\u306a\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u51e6\u7406\u6642\u9593\u306e\u8a08\u6e2c<\/li>\n\n\n\n<li>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u76e3\u8996<\/li>\n\n\n\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565\u306e\u6700\u9069\u5316<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u308c\u3089\u306e\u5b9f\u88c5\u306b\u3088\u308a\u3001\u30bb\u30ad\u30e5\u30a2\u3067\u5b89\u5b9a\u3057\u305f\u753b\u50cf\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-21\">\u6b21\u4e16\u4ee3\u306e\u753b\u50cf\u51e6\u7406\u306b\u5411\u3051\u305f\u767a\u5c55\u7684\u306a\u6d3b\u7528\u65b9\u6cd5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-22\">AI\u3068\u306e\u9023\u643a\u306b\u3088\u308b\u8a8d\u8b58\u753b\u50cf\u6a5f\u80fd\u306e\u5b9f\u73fe<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u753b\u50cf\u8a8d\u8b58AI\u3068Intervention Image\u3092\u7d44\u307f\u5408\u308f\u305b\u305f\u9ad8\u5ea6\u306a\u753b\u50cf\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class AIEnhancedImageProcessor\n{\n    private $imageManager;\n    private $aiClient;\n    private $cache;\n\n    public function __construct(\n        ImageManager $imageManager,\n        AIServiceClient $aiClient,\n        CacheInterface $cache\n    ) {\n        $this-&gt;imageManager = $imageManager;\n        $this-&gt;aiClient = $aiClient;\n        $this-&gt;cache = $cache;\n    }\n\n    public function processWithAI($imagePath, array $options = [])\n    {\n        \/\/ \u30ad\u30e3\u30c3\u30b7\u30e5\u30c1\u30a7\u30c3\u30af\n        $cacheKey = $this-&gt;generateCacheKey($imagePath, $options);\n        if ($cached = $this-&gt;cache-&gt;get($cacheKey)) {\n            return $cached;\n        }\n\n        $image = $this-&gt;imageManager-&gt;make($imagePath);\n\n        \/\/ AI\u5206\u6790\u306e\u5b9f\u884c\n        $aiAnalysis = $this-&gt;performAIAnalysis($image);\n\n        \/\/ \u5206\u6790\u7d50\u679c\u306b\u57fa\u3065\u304f\u753b\u50cf\u51e6\u7406\n        $processedImage = $this-&gt;enhanceImage($image, $aiAnalysis);\n\n        \/\/ \u7d50\u679c\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\n        $this-&gt;cache-&gt;set($cacheKey, [\n            'analysis' =&gt; $aiAnalysis,\n            'processed_path' =&gt; $processedImage-&gt;basePath()\n        ]);\n\n        return [\n            'analysis' =&gt; $aiAnalysis,\n            'processed_path' =&gt; $processedImage-&gt;basePath()\n        ];\n    }\n\n    private function performAIAnalysis($image)\n    {\n        \/\/ \u753b\u50cf\u306e\u30d0\u30a4\u30ca\u30ea\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\n        $imageData = $image-&gt;encode('data-url')-&gt;encoded;\n\n        \/\/ AI\u5206\u6790\u5b9f\u884c\n        $analysis = $this-&gt;aiClient-&gt;analyze($imageData, [\n            'features' =&gt; [\n                'objects',\n                'faces',\n                'text',\n                'colors'\n            ]\n        ]);\n\n        return $analysis;\n    }\n\n    private function enhanceImage($image, $aiAnalysis)\n    {\n        \/\/ \u9854\u691c\u51fa\u306b\u57fa\u3065\u304f\u6700\u9069\u5316\n        if (!empty($aiAnalysis['faces'])) {\n            foreach ($aiAnalysis['faces'] as $face) {\n                $this-&gt;optimizeFaceArea($image, $face);\n            }\n        }\n\n        \/\/ \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u8a8d\u8b58\u306b\u57fa\u3065\u304f\u51e6\u7406\n        if (!empty($aiAnalysis['objects'])) {\n            $this-&gt;optimizeObjectAreas($image, $aiAnalysis['objects']);\n        }\n\n        \/\/ \u30ab\u30e9\u30fc\u30d1\u30ec\u30c3\u30c8\u6700\u9069\u5316\n        if (!empty($aiAnalysis['colors'])) {\n            $this-&gt;optimizeColorBalance($image, $aiAnalysis['colors']);\n        }\n\n        return $image;\n    }\n\n    private function optimizeFaceArea($image, $face)\n    {\n        \/\/ \u9854\u9818\u57df\u306e\u7279\u5225\u306a\u51e6\u7406\uff08\u808c\u30c8\u30fc\u30f3\u6700\u9069\u5316\u306a\u3069\uff09\n        $image-&gt;mask(function ($mask) use ($face) {\n            $mask-&gt;rectangle(\n                $face['x'],\n                $face['y'],\n                $face['width'],\n                $face['height']\n            );\n        })-&gt;brightness(5)-&gt;contrast(10);\n    }\n\n    private function generateCacheKey($imagePath, $options)\n    {\n        return md5($imagePath . serialize($options));\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-23\">\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u3067\u306e\u6d3b\u7528\u4e8b\u4f8b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u30d9\u30fc\u30b9\u306e\u753b\u50cf\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class ImageProcessingMicroservice\n{\n    private $queueClient;\n    private $imageProcessor;\n    private $resultStorage;\n\n    public function __construct(\n        QueueClientInterface $queueClient,\n        ImageProcessor $imageProcessor,\n        StorageInterface $resultStorage\n    ) {\n        $this-&gt;queueClient = $queueClient;\n        $this-&gt;imageProcessor = $imageProcessor;\n        $this-&gt;resultStorage = $resultStorage;\n    }\n\n    public function handleRequest(array $message)\n    {\n        try {\n            \/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\n            $this-&gt;validateMessage($message);\n\n            \/\/ \u753b\u50cf\u51e6\u7406\u30bf\u30b9\u30af\u306e\u5b9f\u884c\n            $result = $this-&gt;processImageTask($message);\n\n            \/\/ \u7d50\u679c\u306e\u4fdd\u5b58\n            $this-&gt;storeResult($message['requestId'], $result);\n\n            \/\/ \u5b8c\u4e86\u901a\u77e5\n            $this-&gt;notifyCompletion($message['requestId'], $result);\n\n        } catch (\\Exception $e) {\n            $this-&gt;handleError($message['requestId'], $e);\n        }\n    }\n\n    private function processImageTask(array $message)\n    {\n        $operations = $this-&gt;parseOperations($message['operations']);\n\n        \/\/ \u753b\u50cf\u51e6\u7406\u306e\u5b9f\u884c\n        return $this-&gt;imageProcessor-&gt;process(\n            $message['sourceUrl'],\n            $operations\n        );\n    }\n\n    private function parseOperations(array $operations)\n    {\n        $validOperations = [];\n\n        foreach ($operations as $operation) {\n            if ($this-&gt;isValidOperation($operation)) {\n                $validOperations[] = $this-&gt;normalizeOperation($operation);\n            }\n        }\n\n        return $validOperations;\n    }\n\n    private function storeResult($requestId, $result)\n    {\n        $this-&gt;resultStorage-&gt;store($requestId, [\n            'status' =&gt; 'completed',\n            'result' =&gt; $result,\n            'timestamp' =&gt; time()\n        ]);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-24\">\u5c06\u6765\u7684\u306a\u62e1\u5f35\u6027\u3092\u8003\u616e\u3057\u305f\u8a2d\u8a08\u30d1\u30bf\u30fc\u30f3<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u62e1\u5f35\u6027\u306e\u9ad8\u3044\u753b\u50cf\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u306e\u5b9f\u88c5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u62bd\u8c61\u5316\u3055\u308c\u305f\u753b\u50cf\u51e6\u7406\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\ninterface ImageProcessorInterface\n{\n    public function process($image, array $operations);\n}\n\n\/\/ \u57fa\u672c\u7684\u306a\u753b\u50cf\u51e6\u7406\u306e\u5b9f\u88c5\nclass BaseImageProcessor implements ImageProcessorInterface\n{\n    protected $manager;\n\n    public function __construct(ImageManager $manager)\n    {\n        $this-&gt;manager = $manager;\n    }\n\n    public function process($image, array $operations)\n    {\n        $processedImage = $this-&gt;manager-&gt;make($image);\n\n        foreach ($operations as $operation) {\n            $this-&gt;applyOperation($processedImage, $operation);\n        }\n\n        return $processedImage;\n    }\n\n    protected function applyOperation($image, $operation)\n    {\n        if (method_exists($image, $operation['name'])) {\n            $image-&gt;{$operation['name']}(...$operation['parameters']);\n        }\n    }\n}\n\n\/\/ \u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u3092\u4f7f\u7528\u3057\u305f\u6a5f\u80fd\u62e1\u5f35\nclass CachingImageProcessor implements ImageProcessorInterface\n{\n    private $processor;\n    private $cache;\n\n    public function __construct(\n        ImageProcessorInterface $processor,\n        CacheInterface $cache\n    ) {\n        $this-&gt;processor = $processor;\n        $this-&gt;cache = $cache;\n    }\n\n    public function process($image, array $operations)\n    {\n        $cacheKey = $this-&gt;generateCacheKey($image, $operations);\n\n        if ($cached = $this-&gt;cache-&gt;get($cacheKey)) {\n            return $cached;\n        }\n\n        $result = $this-&gt;processor-&gt;process($image, $operations);\n        $this-&gt;cache-&gt;set($cacheKey, $result);\n\n        return $result;\n    }\n}\n\n\/\/ \u975e\u540c\u671f\u51e6\u7406\u306b\u5bfe\u5fdc\u3057\u305f\u30d7\u30ed\u30bb\u30c3\u30b5\u30fc\nclass AsyncImageProcessor implements ImageProcessorInterface\n{\n    private $processor;\n    private $queue;\n\n    public function __construct(\n        ImageProcessorInterface $processor,\n        QueueInterface $queue\n    ) {\n        $this-&gt;processor = $processor;\n        $this-&gt;queue = $queue;\n    }\n\n    public function process($image, array $operations)\n    {\n        $jobId = uniqid('img_', true);\n\n        $this-&gt;queue-&gt;push([\n            'jobId' =&gt; $jobId,\n            'image' =&gt; $image,\n            'operations' =&gt; $operations\n        ]);\n\n        return $jobId;\n    }\n}\n\n\/\/ \u4f7f\u7528\u4f8b\n$baseProcessor = new BaseImageProcessor($imageManager);\n$cachingProcessor = new CachingImageProcessor($baseProcessor, $cache);\n$asyncProcessor = new AsyncImageProcessor($cachingProcessor, $queue);\n\n\/\/ \u51e6\u7406\u306e\u5b9f\u884c\n$result = $asyncProcessor-&gt;process('image.jpg', [\n    ['name' =&gt; 'resize', 'parameters' =&gt; [800, 600]],\n    ['name' =&gt; 'brightness', 'parameters' =&gt; [10]]\n]);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b21\u4e16\u4ee3\u306e\u753b\u50cf\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u306b\u304a\u3051\u308b\u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>AI\u9023\u643a<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u753b\u50cf\u8a8d\u8b58\u7d50\u679c\u306e\u52b9\u679c\u7684\u306a\u6d3b\u7528<\/li>\n\n\n\n<li>\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u51e6\u7406\u3068\u975e\u540c\u671f\u51e6\u7406\u306e\u4f7f\u3044\u5206\u3051<\/li>\n\n\n\n<li>\u30ad\u30e3\u30c3\u30b7\u30e5\u6226\u7565\u306e\u6700\u9069\u5316<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b5\u30fc\u30d3\u30b9\u9593\u306e\u758e\u7d50\u5408\u6027\u306e\u78ba\u4fdd<\/li>\n\n\n\n<li>\u30b9\u30b1\u30fc\u30e9\u30d3\u30ea\u30c6\u30a3\u306e\u78ba\u4fdd<\/li>\n\n\n\n<li>\u52b9\u7387\u7684\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u30f3\u30b0<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u62e1\u5f35\u6027\u306e\u78ba\u4fdd<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u30d9\u30fc\u30b9\u306e\u8a2d\u8a08<\/li>\n\n\n\n<li>\u30c7\u30b3\u30ec\u30fc\u30bf\u30fc\u30d1\u30bf\u30fc\u30f3\u306e\u6d3b\u7528<\/li>\n\n\n\n<li>\u30d7\u30e9\u30b0\u30a4\u30f3\u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u306e\u63a1\u7528<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u308c\u3089\u306e\u5b9f\u88c5\u306b\u3088\u308a\u3001\u5c06\u6765\u7684\u306a\u8981\u4ef6\u306e\u5909\u66f4\u3084\u6a5f\u80fd\u8ffd\u52a0\u306b\u3082\u67d4\u8edf\u306b\u5bfe\u5fdc\u3067\u304d\u308b\u753b\u50cf\u51e6\u7406\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-2479","post","type-post","status-publish","format-standard","category-php","nothumb"],"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2479"}],"version-history":[{"count":2,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2479\/revisions"}],"predecessor-version":[{"id":2481,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2479\/revisions\/2481"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}