{"id":10131,"date":"2021-09-30T23:10:36","date_gmt":"2021-09-30T15:10:36","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10131"},"modified":"2021-09-30T23:13:46","modified_gmt":"2021-09-30T15:13:46","slug":"ie-image-local-filter-blur","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2021\/09\/ie-image-local-filter-blur\/","title":{"rendered":"\u517c\u5bb9IE\u6d4f\u89c8\u5668\u7684\u56fe\u7247\u5c40\u90e8\u9ad8\u65af\u6a21\u7cca\u5b9e\u73b0"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10131\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10131<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202109-local-blur.jpg';if(!\/zhangxinxu\/.test(location.host)){document.body.addEventListener('mousedown',function(){location.href='https:\/\/www.zhangxinxu.com\/wordpress\/?p=10131'});}<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/local-blur-cover.jpg\" width=\"480\" height=\"303\" alt=\"\u5c40\u90e8\u6a21\u7cca\u5360\u4f4d\u56fe\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u9700\u6c42\u63cf\u8ff0<\/h3>\n<p>\u9700\u6c42\u662f\u8fd9\u6837\u7684\uff0c\u9700\u8981\u5b9e\u73b0\u4e0b\u56fe\u6240\u793a\u7684\u6a21\u7cca\u6548\u679c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-30_220657.jpg\" width=\"257\" height=\"258\" alt=\"\u5c40\u90e8\u6a21\u7cca\u6548\u679c\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e24\u4e2a\u96be\u70b9\uff0c\u4e00\u662f\u5c40\u90e8\u6a21\u7cca\uff0c\u4e8c\u662f\u6a21\u7cca\u7684\u8fb9\u7f18\u662f\u7fbd\u5316\u7684\uff0c\u800c\u4e0d\u662f\u7a81\u7136\u622a\u65ad\u7684\u3002<\/p>\n<p>\u8fd9\u4e2a\u9700\u6c42\u8be5\u5982\u4f55\u5b9e\u73b0\u5462\uff1f<\/p>\n<h3>\u4e8c\u3001\u6211\u7684\u5b9e\u73b0\u601d\u8def<\/h3>\n<p>\u6211\u7684\u5b9e\u73b0\u601d\u8def\u5206\u4e3a3\u6b65\uff1a<\/p>\n<ol>\n<li>\u7ed8\u5236\u4e24\u5c42 Canvas\uff0c\u4e0b\u5c42 Canvas \u662f\u5b8c\u6574\u7684\u56fe\u50cf\uff0c\u800c\u4e0a\u5c42 Canvas \u8fd1\u7ed8\u5236\u9700\u8981\u6a21\u7cca\u7684\u533a\u57df\uff1b<\/li>\n<li>\u6a21\u7cca\u4e0a\u5c42 Canvas\uff0c\u793a\u610f\u56fe\u5982\u4e0b\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-30_221055.jpg\" width=\"366\" height=\"319\" alt=\"\u6a21\u7cca\u5206\u4e3a\u4e24\u5c42\" class=\"alignnone size-medium\" \/><\/li>\n<li>\u4e24\u5c42 Canvas \u5408\u4e8c\u4e3a\u4e00\u3002<\/li>\n<\/ol>\n<p>\u5176\u4e2d\uff0c\u5b9e\u73b0\u601d\u8def1\u548c3\u90fd\u53ef\u4ee5\u4f7f\u7528 Canvas \u7684 <code>drawImage()<\/code> \u65b9\u6cd5\u5b9e\u73b0\uff0c\u8fd9\u4e2a\u6bd4\u8f83\u5165\u95e8\uff0c\u6709\u6311\u6218\u7684\u662f\u7b2c2\u6b65\uff0c\u5982\u4f55\u6a21\u7cca\u4e00\u4e2a Canvas \u56fe\u50cf\uff1f<\/p>\n<p>\u5982\u679c\u662f\u5728 CSS \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 CSS <code>filter<\/code> \u6ee4\u955c\u5c5e\u6027\u4e00\u6b65\u5230\u4f4d\uff0c\u8981\u662f\u5728 Canvas \u4e2d\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 <code>filter<\/code> \u6ee4\u955c\u5c5e\u6027\u5c31\u597d\u4e86\uff1f<\/p>\n<p>\u606d\u559c\u4f60\uff01\u613f\u671b\u6210\u771f\u4e86\uff0cCanvas \u8fd8\u771f\u5c31\u65b0\u652f\u6301\u4e86\u4e00\u4e2a filter \u5c5e\u6027\uff0c\u53ef\u4ee5\u5b9e\u73b0\u5728 Canvas \u753b\u5e03\u4e2d\u7684\u5404\u79cd\u6ee4\u955c\u6548\u679c\uff0c\u4e0d\u4ec5\u662f\u6a21\u7cca\uff0c\u53cd\u76f8\u3001\u9971\u548c\u5ea6\u3001\u8272\u8c03\u65cb\u8f6c\u3001\u7070\u5ea6\u7b49 10 \u4e2a\u6ee4\u955c\u51fd\u6570\u5168\u90e8\u90fd\u652f\u6301\u3002<\/p>\n<p><span class=\"hidden\">\/\/zxx: \u5982\u679c\u4f60\u770b\u5230\u8fd9\u6bb5\u6587\u5b57\uff0c\u8bf4\u660e\u4f60\u73b0\u5728\u8bbf\u95ee\u662f\u4e0d\u662f\u539f\u6587\u7ad9\u70b9\uff0c\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u5728\u8fd9\u91cc\uff1ahttps:\/\/www.zhangxinxu.com\/wordpress\/?p=10131\uff08\u4f5c\u8005\u5f20\u946b\u65ed\uff09<\/span><\/p>\n<h3>\u4e09\u3001canvas filter\u6ee4\u955c\u51fd\u6570<\/h3>\n<p>Canvas filter \u6ee4\u955c\u652f\u6301\u7684\u6ee4\u955c\u51fd\u6570\u6709\u4e0b\u8868\u8fd9\u4e9b\uff1a<\/p>\n<table class=\"params_table\" style=\"max-width:480px;\" border=\"0\" cellspacing=\"1\">\n<thead>\n<tr>\n<th>\u6ee4\u955c\u51fd\u6570<\/th>\n<th>\u91ca\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>url(#someId)<\/td>\n<td>\u4f7f\u7528ID\u662fsomeId\u7684SVG\u6ee4\u955c<\/td>\n<\/tr>\n<tr>\n<td>blur(5px)<\/td>\n<td>\u6a21\u7cca<\/td>\n<\/tr>\n<tr>\n<td>brightness(2.4)<\/td>\n<td>\u4eae\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>contrast(200%)<\/td>\n<td>\u5bf9\u6bd4\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>drop-shadow(4px 4px 8px blue)<\/td>\n<td>\u6295\u5f71<\/td>\n<\/tr>\n<tr>\n<td>grayscale(50%)<\/td>\n<td>\u7070\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>hue-rotate(90deg)<\/td>\n<td>\u8272\u8c03\u53d8\u5316<\/td>\n<\/tr>\n<tr>\n<td>invert(75%)<\/td>\n<td>\u53cd\u76f8<\/td>\n<\/tr>\n<tr>\n<td>opacity(25%)<\/td>\n<td>\u900f\u660e\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>saturate(230%)<\/td>\n<td>\u9971\u548c\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>sepia(60%)<\/td>\n<td>\u8910\u8272<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5404\u4e2a\u6ee4\u955c\u6548\u679c\u53ef\u4ee5\u89c1\u6b64<a href=\"https:\/\/www.canvasapi.cn\/CanvasRenderingContext2D\/filter\" target=\"_canvasapi\">\u6587\u6863\u9875\u9762<\/a>\u3002<\/p>\n<p>\u5728\u672c\u4f8b\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u7684\u6ee4\u955c\u51fd\u6570\u5c31\u662f <code>blur()<\/code> \u6a21\u7cca\u51fd\u6570\uff0c\u4f7f\u7528\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>context.filter = 'blur(5px)';\r\n<span class=\"green\">\/\/ \u6b64\u65f6\u7ed8\u5236\u7684\u56fe\u50cf\u5c31\u662f\u6a21\u7cca\u7684<\/span>\r\ncontext.drawImage(...)<\/pre>\n<p>\u662f\u4e0d\u662f\u76f8\u5f53\u7b80\u5355\uff1f\u4f60\u4ee5\u4e3a\u9700\u6c42\u5c31\u8fd9\u4e48\u8f7b\u677e\u5b9e\u73b0\u4e86\u5417\uff1f<\/p>\n<p>\u975e\u4e5f\uff0cfilter \u5c5e\u6027\u867d\u7136\u597d\u7528\uff0c\u4f46\u662f\u517c\u5bb9\u6027\u60c5\u51b5\u5374\u4e0d\u5bb9\u4e50\u89c2\uff0c\u5c24\u5176 Safari \u6d4f\u89c8\u5668\u5e76\u4e0d\u652f\u6301\uff0c\u8fd9\u5c31\u597d\u6bd4\u4e1d\u7ebf\u6253\u7ed3\u2014\u2014\u96be\u89e3\u4e86\u3002<\/p>\n<p>\u6b64\u65f6\uff0c\u53ea\u80fd\u51fa\u52a8\u539f\u59cb\u7684\u9ad8\u65af\u6a21\u7cca\u7b97\u6cd5\uff0c\u5bf9\u56fe\u50cf\u8fdb\u884c\u5904\u7406\u4e86\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u6211\u4eec\u65e0\u9700\u81ea\u5df1\u7f16\u5199\uff0c\u53ef\u4ee5\u53bb GitHub \u4e0a\u627e\u627e\u5f00\u6e90\u7684\u5904\u7406\u3002<\/p>\n<p>\u6211\u572813\u5e74\u7684\u65f6\u5019\u6709\u7bc7\u6587\u7ae0\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2013\/11\/css-svg-image-blur\/\">\u4f7f\u7528CSS\u5c06\u56fe\u7247\u8f6c\u6362\u6210\u6a21\u7cca(\u6bdb\u73bb\u7483)\u6548\u679c<\/a>\u201d\u4e2d\u63d0\u5230\u4e86\u4e00\u4e2a\u540d\u4e3a StackBlur \u7684\u9879\u76ee\uff0c<a href=\"https:\/\/github.com\/flozz\/StackBlur\" rel=\"noopener\" target=\"_github\">https:\/\/github.com\/flozz\/StackBlur<\/a><\/p>\n<p>\u6253\u5f00\u4e00\u770b\uff0c\u9879\u76ee\u8fd8\u5728\uff0cStar\u6570\u76ee\u4e5f\u4e0d\u5c11\uff0c\u770b\u8d77\u6765\u8fd8\u633a\u9760\u8c31\uff0c\u7136\u800c\u4e00\u756a\u5b9e\u8df5\u4e0b\u6765\uff0c\u53d1\u73b0\u4e0d\u9002\u5408\u8fd9\u91cc\u7684\u9700\u6c42\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-27_152341.png\" width=\"421\" height=\"143\" alt=\"StackBlur Star\u6570\u76ee\"><\/p>\n<h3>\u56db\u3001StackBlur \u7684\u95ee\u9898<\/h3>\n<p>\u53ef\u80fd\u662f\u4e3a\u4e86\u4fdd\u8bc1\u9ad8\u6027\u80fd\uff0cStackBlur \u7684\u6a21\u7cca\u7b97\u6cd5\u770b\u8d77\u6765\u662f\u975e\u5bf9\u79f0\u7684\uff0c\u5982\u679c\u662f\u8fb9\u7f18\u7280\u5229\u7684\u9ad8\u65af\u6a21\u7cca\uff0cStackBlur \u7edd\u5bf9\u6ca1\u6709\u4efb\u4f55\u95ee\u9898\uff0c\u8868\u73b0\u975e\u5e38\u826f\u597d\uff0c\u4f46\u662f\uff0c\u5982\u679c\u662f\u8fd9\u91cc\u7684\u56db\u5468\u900f\u660e\u7684\u9ad8\u65af\u6a21\u7cca\uff0c\u5c31\u4f1a\u51fa\u73b0\u767d\u8fb9\u6216\u8005\u9ed1\u7ebf\uff0c\u4ee5\u53ca\u6700\u7ec8\u5f62\u72b6\u4e0d\u89c4\u5219\u7684\u95ee\u9898\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-27_153305.jpg\" width=\"183\" height=\"360\" alt=\"StackBlur \u7684\u95ee\u9898\u793a\u610f\"><\/p>\n<p>\u6211\u8fd8\u4e13\u95e8\u505a\u4e86\u4e2a\u7b80\u6613demo\u5c55\u73b0\u6b64\u95ee\u9898\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202109\/blur.html\" class=\"a_link\" target=\"_blank\">StackBlur \u767d\u8fb9\u9ed1\u7ebf\u95ee\u9898 demo<\/a><\/p>\n<p>\u4e5f\u7ed9\u76f8\u5173 Issues \u8865\u5145\u4e86\u5173\u4e8e\u6b64\u95ee\u9898\u7684\u590d\u73b0\u63cf\u8ff0\uff0c\u4e0d\u8fc7\u4f5c\u8005\u4e00\u76f4\u6ca1\u6709\u56de\u590d\uff0c\u4f30\u8ba1\u8fd9\u4e2a\u95ee\u9898\u4e0d\u592a\u597d\u89e3\u51b3\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-27_153807.png\" width=\"662\" height=\"183\" alt=\"Issues\u53cd\u9988\u622a\u56fe\"><\/p>\n<p>\u53ef\u662f\u9700\u6c42\u4e0d\u7b49\u4eba\uff0c\u90a3\u5c31\u5bfb\u627e\u6bd4\u8f83\u6b63\u7edf\u7684\u9ad8\u65af\u6a21\u7cca\u7b97\u6cd5\u3002<\/p>\n<h3>\u4e94\u3001\u627e\u5230\u65b0\u7684\u89e3\u51b3\u5de5\u5177<\/h3>\n<p>\u627e\u554a\u627e\uff0c\u627e\u554a\u627e\uff0c\u627e\u5230\u4e86\u4e00\u4e2a\u5176\u8c8c\u4e0d\u626c\u7684\u9879\u76ee\uff1a<a href=\"https:\/\/github.com\/finscn\/SimpleBlur\" rel=\"noopener\" target=\"_github\">https:\/\/github.com\/finscn\/SimpleBlur<\/a><\/p>\n<p>\u8fd9\u4e2a\u9879\u76ee\u53ca\u5176\u7b80\u964b\uff0c\u5c31\u4e00\u4e2a JS \u6587\u4ef6\u52a0\u51e0\u884c ReadMe\uff0cStar \u6570\u91cf\u53ea\u6709 1 \u4e2a\uff0c\u800c\u4e14\u662f 8 \u5e74\u524d\u7684\u9879\u76ee\uff0c\u4e5f\u5c31\u662f\u53d1\u5e03\u540e\u52a8\u90fd\u6ca1\u52a8\u8fc7\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-27_154406.png\" width=\"728\" height=\"341\" alt=\"\u9879\u76ee\u7b80\u964b\u793a\u610f\"><\/p>\n<p>\u4e0d\u7981\u8ba9\u4eba\u6000\u7591\uff0c\u8fd9\u4e2a\u9879\u76ee\u9760\u8c31\u4e48\uff1f<\/p>\n<p>\u9760\u4e0d\u9760\u8c31\u8fd8\u662f\u8981\u901a\u8fc7\u5b9e\u8df5\u624d\u77e5\u9053\u3002<\/p>\n<p>\u6211\u5c31\u6574\u4e2a\u4e2a\u7b80\u6613 demo \u8dd1\u4e86\u4e0b\uff0c\u6211\u53bb\uff0c\u6548\u679c\u8d3c\u597d\uff0c\u5c31\u662f\u6027\u80fd\u5dee\u5230\u8981\u7838\u7535\u8111\uff0c\u6709\u591a\u5dee\u5462\uff0c\u4e00\u5f20 600 * 800 \u50cf\u7d20\u7684\u56fe\u3002\u6a21\u7cca\u534a\u5f84\u662f 40\uff0c\u7ed3\u679c\u5728 IE Edge\uff08\u5c31\u662f IE11 \u6d4f\u89c8\u5668\uff09\u4e0b\uff0c\u5c45\u7136\u8981 20s\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-27_155849.jpg\" width=\"388\" height=\"503\" alt=\"\u8fd0\u884c\u65f6\u95f4\u793a\u610f\"><\/p>\n<p>\u662f\u4e0d\u662f\u627e\u5230 Star \u6570\u91cf\u5982\u6b64\u4f4e\u7684\u539f\u56e0\u4e86\uff0c\u8fd9\u79cd\u6027\u80fd\uff0c\u663e\u7136\u662f\u4e0d\u80fd\u7528\u5728\u751f\u4ea7\u73af\u5883\u7684\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u5b9e\u5728\u662f\u67b6\u4e0d\u4f4f\u6700\u7ec8\u7684\u6548\u679c\u5c31\u662f\u81ea\u5df1\u60f3\u8981\u7684\uff0c\u4e8e\u662f\u6211\u5c31\u6253\u5f00\u6e90\u7801\uff0c\u6253\u7b97\u5e2e\u5fd9\u4f18\u5316\u4e0b\u6027\u80fd\uff0c\u7ed3\u679c\u53d1\u73b0\u4f5c\u8005\u8fd8\u63d0\u4f9b\u4e86\u53e6\u5916\u4e00\u79cd\u7b97\u6cd5\u5b9e\u73b0\uff0c\u57fa\u4e8e\u77e9\u9635\u7684\uff0c\u5c31\u5728\u4ee3\u7801\u4e2d\uff0c\u6211\u6574\u4e2a\u4eba\u61f5\u4e86\uff0c\u4f46\u5f88\u5feb\u5c31\u641e\u61c2\u4e86\u3002<\/p>\n<p>\u4f5c\u8005\u793a\u610f\u7684\u4ee3\u7801\u4e2d\u6709\u4e2a\u53c2\u6570\u4e3a <code>gaussian<\/code>\uff0c\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>var blur = new Blur({\r\n    radius: 20,\r\n    gaussian : true,\r\n});\r\nblur.init();<\/pre>\n<p>\u4f7f\u7528\u7684\u503c\u662f <code>true<\/code>\uff0c\u6027\u80fd\u95ee\u9898\u5c31\u51fa\u5728\u8fd9\u4e2a <code>true<\/code> \u4e0a\uff0c\u5982\u679c\u4f5c\u8005\u793a\u610f\u7684\u4ee3\u7801\u662f <code>false<\/code>\uff0c\u6211\u4f30\u8ba1 Star \u6570\u76ee\u4f1a\u591a\u4e0d\u5c11\uff0c\u56e0\u4e3a\uff0c\u5982\u679c <code>gaussian<\/code> \u53c2\u6570\u7684\u503c\u662f <code>false<\/code>\uff0c\u4f7f\u7528\u7684\u662f\u53e6\u5916\u90a3\u4e00\u79cd\u7684\u6027\u80fd\u9ad8\u5f88\u591a\u7684\u6a21\u7cca\u7b97\u6cd5\u3002<\/p>\n<p>\u518d\u6765\u8bd5\u8bd5\u8fd0\u884c\u6548\u679c\uff1a<\/p>\n<pre>new Blur({\r\n    radius: 40,\r\n    gaussian: false\r\n})<\/pre>\n<p>\u6b64\u65f6\uff0c\u540c\u6837\u7684\u56fe\u50cf\uff0c\u540c\u6837\u7684\u6a21\u7cca\u534a\u5f84\uff0c\u5728 IE 11 \u6d4f\u89c8\u5668\u4e0b\uff0c\u53ea\u9700\u8981 1 \u79d2\u5c31\u5b8c\u6210\u4e86\uff0c\u901f\u5ea6\u63d0\u5347\u4e86 20 \u591a\u500d\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-27_164054.jpg\" width=\"398\" height=\"484\" alt=\"\u53e6\u5916\u4e00\u79cd\u7b97\u6cd5\u6548\u7387\"><\/p>\n<p>Chrome \u6d4f\u89c8\u5668\u4e0b\u4ec5\u9700\u8981 170 \u6beb\u79d2\u5de6\u53f3\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-27_164410.jpg\" width=\"421\" height=\"249\" alt=\"Chrome\u4e0b\u8fd0\u884c\u4e8b\u4ef6\"><\/p>\n<p>\u8fd9\u4e2a\u6027\u80fd\u5b8c\u5168\u53ef\u4ee5\u5728\u9879\u76ee\u4e2d\u4f7f\u7528\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u8fd9\u91cc\u7684 Blur.js \u4e0d\u662f\u4e0d\u80fd\u7528\uff0c\u800c\u662f\u4e0d\u80fd\u6309\u7167 ReadMe \u63d0\u4f9b\u7684\u7528\u6cd5\u7528\u3002<\/p>\n<h3>\u516d\u3001\u6574\u5408\u3001\u6700\u7ec8\u6548\u679c\u4e0e\u5f00\u6e90<\/h3>\n<p>\u641e\u5b9a\u4e86 IE \u6d4f\u89c8\u5668\u548c Safari \u6d4f\u89c8\u5668\u4e0b\u7684\u6a21\u7cca\u5b9e\u73b0\uff0c\u5269\u4e0b\u7684\u5c31\u662f\u6574\u5408\u4e86\u3002<\/p>\n<p>\u652f\u6301 filter \u6ee4\u955c\u7684\u4f7f\u7528\u539f\u751f\u7684\u6ee4\u955c\uff0c\u4e0d\u652f\u6301\u7684\u4f7f\u7528 Blur.js \u8fdb\u884c\u6a21\u7cca\u5904\u7406\u3002<\/p>\n<p>\u5982\u679c\u5224\u65ad\u6d4f\u89c8\u5668\u7684 canvas \u662f\u5426\u652f\u6301 filter \u5c5e\u6027\u5462\uff1f<\/p>\n<p>\u5343\u4e07\u4e0d\u8981\u57fa\u4e8e\u6d4f\u89c8\u5668\u5224\u65ad\uff0c\u56e0\u4e3a\u67d0\u4e9b Android \u8bbe\u5907\u4ee5\u53ca\u67d0\u4e9b APP \u4f7f\u7528\u7684\u5185\u6838\u7406\u8bba\u4e0a\u5e94\u8be5\u652f\u6301\uff0c\u5b9e\u9645\u4e0a\u5e76\u6ca1\u6709\u652f\u6301\u3002<\/p>\n<p>\u6211\u4f7f\u7528\u5224\u65ad\u65b9\u6cd5\u5982\u4e0b\uff08<code>context<\/code> \u662f\u4efb\u610f canvas \u7684\u4e0a\u4e0b\u6587\uff09\uff1a<\/p>\n<pre>var isSupportFilter = (typeof context.filter === 'string');<\/pre>\n<p>\u5047\u8bbe\u9700\u8981\u7ed8\u5236\u7684\u56fe\u5f62\u5143\u7d20\u662f <code>img<\/code>\uff0c\u5219\u6574\u5408\u540e\u7684\u6267\u884c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>\/\/ \u6267\u884c\u6a21\u7cca\r\nif (typeof context.filter == 'string') {\r\n    \/\/ \u652f\u6301canvas\u6ee4\u955c\r\n    context.filter = 'blur(10px)';\r\n    \/\/ \u7ed8\u5236\u5c40\u90e8\u56fe\u50cf\r\n    context.drawImage(img, arrParamsDraw);\r\n} else {\r\n    \/\/ \u4e0d\u652f\u6301Canvas\u6ee4\u955c\r\n    \/\/ \u4f7f\u7528\u7b2c\u4e09\u65b9\u65b9\u6cd5\r\n    var blurFixed = new Blur({\r\n        radius: numRadius,\r\n        gaussian : false\r\n    });\r\n    blurFixed.init();\r\n    \/\/ \u5148\u7ed8\u5236\u5c40\u90e8\u56fe\u50cf\r\n    context.drawImage(img, 0, 0);\r\n    \/\/ \u518d\u6267\u884c\u6a21\u7cca\r\n    var imgBlured = blurFixed.blurRGBA(canvas, null, true);\r\n}<\/pre>\n<p>\u8fd9\u6837\uff0c\u5c31\u80fd\u5b9e\u73b0 IE9 \u53ca\u5176\u4ee5\u4e0a\u6d4f\u89c8\u5668\u7684\u5168\u90e8\u517c\u5bb9\u4e86\u3002<\/p>\n<h4>\u4ee3\u7801\u5c01\u88c5\u4e0e gitee \u5f00\u6e90<\/h4>\n<p>\u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u4f7f\u7528\uff0c\u6211\u628a\u76f8\u5173\u7684\u5904\u7406\u5168\u90e8\u7528\u4e00\u4e2a\u65b9\u6cd5\u5c01\u88c5\u8d77\u6765\u4e86\uff0c\u5e76\u4e14\u5f00\u6e90\u5230\u4e86 gitee \u4e0a\uff0c\u5730\u5740\u662f\uff1a<a href=\"https:\/\/gitee.com\/zhangxinxu\/local-blur\" rel=\"noopener\" target=\"_blank\">https:\/\/gitee.com\/zhangxinxu\/local-blur<\/a><\/p>\n<p>\u5982\u679c\u4f60\u89c9\u5f97\u9879\u76ee\u8fd8\u4e0d\u9519\uff0c\u6b22\u8fce Star \u8be5\u9879\u76ee\u3002<\/p>\n<p>\u5c01\u88c5\u597d\u7684 JS \u5c31\u662f\u4e0b\u9762\u7684 <a href=\"https:\/\/gitee.com\/zhangxinxu\/local-blur\/raw\/master\/localBlur.js\" rel=\"noopener\" target=\"_blank\">localBlur.js<\/a>\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-30_221942.png\" width=\"453\" height=\"275\" alt=\"\u5f00\u6e90JS\u6587\u4ef6\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u5c01\u88c5\u7684\u65b9\u6cd5\u540d\u5c31\u662f localBlur\uff0c\u5177\u4f53\u4f7f\u7528\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u5f15\u5165 localBlur.js\n<pre>&lt;script src=\".\/localBlur.js\"&gt;&lt;\/script&gt;<\/pre>\n<\/li>\n<li>\u8c03\u7528 localBlur \u65b9\u6cd5\n<pre>localBlur(source, radius, bounding, output);\r\n\/\/ \u6216\u8005\r\nlocalBlur(src, radius, bounding, callback);<\/pre>\n<\/li>\n<\/ol>\n<p><strong>\u5176\u4e2d\uff1a<\/strong><\/p>\n<dl>\n<dt>source<\/dt>\n<dd>\u8868\u793a\u539f\u59cb\u56fe\u50cf\u8d44\u6e90\uff0c\u53ef\u4ee5\u662f <code>&lt;img&gt;<\/code> \u56fe\u50cf\u5143\u7d20\uff0c\u4e5f\u53ef\u4ee5\u662f <code>&lt;canvas&gt;<\/code> \u753b\u5e03\u5143\u7d20\u3002<\/dd>\n<dt>src<\/dt>\n<dd>\u8868\u793a\u539f\u59cb\u56fe\u50cf\u7684 URL \u5730\u5740\uff0c\u6ce8\u610f\u8de8\u57df\u7684\u95ee\u9898\u3002<\/dd>\n<dt>radius<\/dt>\n<dd>\u6570\u503c\uff0c\u5fc5\u9700\uff0c\u8868\u793a\u6a21\u7cca\u534a\u5f84\u3002<\/dd>\n<dt>bounding<\/dt>\n<dd>\u6570\u7ec4\uff0c\u53ef\u9009\uff0c\u8868\u793a\u6a21\u7cca\u7684\u5c40\u90e8\u533a\u57df\u8303\u56f4\uff0c\u7531 4 \u4e2a\u503c\u7ec4\u6210\uff0c<code>[x, y, width, height]<\/code>, \u5206\u522b\u8868\u793a\u533a\u57df\u7684\u5de6\u4e0a\u89d2\u5750\u6807\u548c\u5bbd\u9ad8\u5927\u5c0f\uff0c\u4f8b\u5982 <code>[20, 20, 240, 120]<\/code>\uff0c\u8868\u793a\u56fe\u50cf\u4e0a\u6a2a\u5750\u6807 20px\uff0c\u7eb5\u5750\u6807 20px\u4e3a\u5de6\u4e0a\u89d2\uff0c\u5bbd\u5ea6\u662f 240px\uff0c\u9ad8\u5ea6\u662f 120px \u7684\u77e9\u5f62\u533a\u57df\u53d1\u751f\u6a21\u7cca\u3002<\/dd>\n<dt>output<\/dt>\n<dd>\u663e\u793a\u6700\u7ec8\u6a21\u7cca\u6548\u679c\u7684 <code>&lt;canvas&gt;<\/code> \u753b\u5e03\u5143\u7d20\u3002<\/dd>\n<dt>callback<\/dt>\n<dd>\u663e\u793a\u6700\u7ec8\u6a21\u7cca\u6548\u679c\u7684\u56de\u8c03\u51fd\u6570\uff0c\u652f\u6301\u4e00\u4e2a\u53c2\u6570\uff0c\u8868\u793a\u5305\u542b\u6a21\u7cca\u6548\u679c\u7684 <code>&lt;canvas&gt;<\/code> \u753b\u5e03\u5143\u7d20\u3002<\/dd>\n<\/dl>\n<h4>\u6700\u7ec8\u6848\u4f8b\u6548\u679c<\/h4>\n<p>\u5c01\u88c5\u7684\u65b9\u6cd5\u6709\u4e86\uff0c\u90a3\u4e48\u6548\u679c\u5982\u4f55\u5462\uff1f<\/p>\n<p>\u9879\u76ee\u4e2d\u7684 index.html \u5c31\u662f\u6f14\u793a\u9875\u9762\uff0c\u4e0d\u8fc7 gitee \u7684 pages \u529f\u80fd\u6ca1\u5f00\u53d1\uff0c\u5927\u5bb6\u4e5f\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\u4f53\u9a8c\u6548\u679c\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202109\/image-local-gaussian-blur-demo.php\" rel=\"noopener\" target=\"_blank\">\u517c\u5bb9Safari\/IE\u7684\u5c40\u90e8\u9ad8\u65af\u6a21\u7ccademo<\/a><\/p>\n<p>\u5982\u679c\u624b\u673a\u8bbf\u95ee\u7684\uff0c\u4e0d\u65b9\u4fbf\u4f53\u9a8c\uff0c\u4e5f\u53ef\u4ee5\u89c2\u770b\u4e0b\u9762\u7684\u89c6\u9891\u611f\u53d7\u4e0b\u5b9e\u73b0\u6548\u679c\uff08\u4e0d\u52a8\u70b9\u51fb\u64ad\u653e\uff09\uff1a<\/p>\n<p><video src='\/\/image.zhangxinxu.com\/video\/blog\/202109\/local-blur.mp4' type=\"video\/mp4\" width=\"274\" height=\"706\" preload=\"auto\" autoplay autobuffer loop x-webkit-airplay=\"allow\" x5-video-player-type=\"h5\" x5-video-player-fullscreen=\"true\" x5-video-orientation=\"portraint\" webkit-playsinline=\"true\" playsinline=\"true\" \u200b\u200b\u200b\u200bposter=\"\/\/image.zhangxinxu.com\/image\/blog\/201806\/poster.png\"><\/video><\/p>\n<p>\u6838\u5fc3\u5b9e\u73b0\u5176\u5b9e\u5c31\u8fd9\u4e48\u4e00\u53e5\uff1a<\/p>\n<pre>localBlur(source, 10, [76,40,360,240], output);<\/pre>\n<p>\u5176\u4ed6\uff1a\u76ee\u6807\u56fe\u50cf\u5c3a\u5bf8\u8d8a\u5c0f\uff0c\u6027\u80fd\u7ea6\u597d\uff0c\u6a21\u7cca\u534a\u5f84\u8d8a\u5c0f\uff0c\u6027\u80fd\u4e5f\u7ea6\u597d\uff0c\u8fd9\u4e00\u70b9\u5728 IE \u6d4f\u89c8\u5668\u4e0a\u66f4\u4e3a\u660e\u663e\u3002<\/p>\n<h4>\u6b22\u8fce\u5173\u6ce8\u6211\u7684gitee<\/h4>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684 gitee \u8d26\u6237\uff0c<a href=\"https:\/\/gitee.com\/zhangxinxu\/\" rel=\"noopener\" target=\"_blank\">https:\/\/gitee.com\/zhangxinxu\/<\/a> \u4ee5\u540e\u5199\u5c0f\u73a9\u5177\u5168\u90e8\u90fd\u4f1a\u6254\u5728\u4e0a\u9762\uff0c\u56e0\u4e3a\u901f\u5ea6\u5feb\uff0c\u76ee\u524d\u5df2\u7ecf\u670910\u4e2a\u5c0f\u73a9\u5177\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/2021-09-30_224939.png\" width=\"347\" height=\"422\" alt=\"\u5173\u6ce8\u6211\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u4e03\u3001\u7ed3\u675f\u4e4b CSS \u4e5f\u53ef\u4ee5\u5b9e\u73b0<\/h3>\n<p>\u5982\u679c\u4e0d\u9700\u8981\u517c\u5bb9 IE \u6d4f\u89c8\u5668\uff0c\u6216\u8005\u4e0d\u9700\u8981\u6700\u7ec8\u5408\u6210\u4e00\u5f20\u56fe\u7247\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u8fd8\u662f\u4f7f\u7528 CSS \u5b9e\u73b0\uff0c\u5177\u4f53\u4e0d\u8868\uff0c\u53ef\u53c2\u89c1\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2013\/11\/css-svg-image-blur\/\">\u4f7f\u7528CSS\u5c06\u56fe\u7247\u8f6c\u6362\u6210\u6a21\u7cca(\u6bdb\u73bb\u7483)\u6548\u679c<\/a>\u201d\u8fd9\u7bc7\u6587\u7ae0\u3002<\/p>\n<p>\u524d\u4e24\u5929\uff0c\u7f16\u8f91\u8ddf\u6211\u8bf4\u300aCSS\u65b0\u4e16\u754c\u300b\u91cd\u5370\u4e86\uff0c\u8bf4\u5b9e\u8bdd\uff0c\u51fa\u4e4e\u4e86\u6211\u7684\u610f\u6599\uff0c\u6ca1\u60f3\u5230\u8fd9\u4e48\u5feb\u5c31\u91cd\u5370\u4e86\uff0c\u6bd5\u7adf\u9996\u5370\u8db3\u8db3\u67094000\u518c\uff0c\u5728\u8fd9\u91cc\uff0c\u7279\u522b\u611f\u8c22\u5927\u5bb6\u7684\u652f\u6301\uff0c\u76ee\u524d\u5fae\u535a\u8fd8\u6709\u8f6c\u53d1\u62bd\u5956\uff0c\u5982\u679c\u4e0d\u5acc\u9ebb\u70e6\u7684\uff0c\u53ef\u4ee5\u8f6c\u53d1\u4e0b\uff0c\u8bf4\u4e0d\u5b9a\u53ef\u4ee5\u83b7\u5f97\u300aCSS\u65b0\u4e16\u754c\u300b\u7684\u7b7e\u5b57\u7248\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/print-again.jpg\" width=\"375\" height=\"209\" alt=\"\u91cd\u5370\u622a\u56fe\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u8fd8\u67091\u4e2a\u5c0f\u65f6\u5c31\u662f\u56fd\u5e86\u8282\u4e86\uff0c\u7b97\u662f\u9a6c\u4e0d\u505c\u8e44\u57289\u6708\u4efd\u7684\u672b\u5c3e\u8d76\u51fa\u6765\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5982\u679c\u60a8\u89c9\u5f97\u6587\u7ae0\u5185\u5bb9\u8fd8\u4e0d\u9519\uff0c\u6b22\u8fce\u8f6c\u53d1\uff0c\u6b22\u8fce\u5206\u4eab\u3002<\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u795d\u6240\u6709\u7684\u524d\u7aef\u540c\u884c\u56fd\u5e86\u8282\u5feb\u4e50\uff0c\u4e00\u5207\u987a\u987a\u5229\u5229\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/emtion\/emoji\/2764.svg\" width=\"20\" height=\"20\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10131\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10131<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202109\/local-blur-cover.jpg\" width=\"160\" height=\"101\" alt=\"\u5c40\u90e8\u6a21\u7cca\u5360\u4f4d\u56fe\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>CSS\u5b9e\u73b0\u9ad8\u65af\u6a21\u7cca\u5f88\u65b9\u4fbf\uff0c\u4f46\u662f\u5982\u679c\u8981\u517c\u5bb9IE\u600e\u4e48\u529e\uff0c\u5982\u679c\u5e0c\u671b\u5c40\u90e8\u6a21\u7cca\u600e\u4e48\u529e\uff0c\u5982\u679c\u5e0c\u671b\u6a21\u7cca\u7684\u56fe\u50cf\u6709\u5408\u6210\u80fd\u529b\u600e\u4e48\u529e\uff0c\u6b64\u65f6\uff0c\u8fd8\u662f\u5f97\u501f\u52a9 canvas\uff0c\u672c\u6587\u5c31\u6df1\u5165\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 canvas \u5b9e\u73b0\u5e26\u7fbd\u5316\u7684\u5c40\u90e8\u6a21\u7cca\u6548\u679c\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[896],"tags":[53,885,886],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10131"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=10131"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10131\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}