{"id":2536,"date":"2018-02-27T14:53:55","date_gmt":"2018-02-27T06:53:55","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2536"},"modified":"2018-02-27T14:53:55","modified_gmt":"2018-02-27T06:53:55","slug":"html5-%e5%ae%9e%e7%8e%b0-alarm-%e5%a3%81%e7%ba%b8%e7%9a%84%e5%89%aa%e8%a3%81smartcrop-js-%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2536","title":{"rendered":"HTML5 \u5b9e\u73b0 alarm \u58c1\u7eb8\u7684\u526a\u88c1(smartcrop.js \u6559\u7a0b)"},"content":{"rendered":"<p>\n\tHTML5 \u5f88\u5f3a\u5927\uff0c\u6216\u8005\u8bf4 JavaScript \u7f16\u7a0b\u8bed\u8a00\u5f88\u5f3a\u5927\uff0c\u5b83\u4eec\u80fd\u5728\u7f51\u9875\u4e0a\u5b9e\u73b0\u667a\u80fd\u526a\u88c1\u3002\u5236\u4f5c\u5404\u79cd\u5404\u6837\u7684\u58c1\u7eb8\uff0c\u4f8b\u5982\uff1aalarm\u58c1\u7eb8\u3002\u5728\u8fd8\u6709\u56fe\u7247\u7684\u58c1\u7eb8\u4e0a\uff0c\u80fd\u667a\u80fd\u7684\u5206\u8fa8\u51fa\u4eba\u8138\u7b49\u3002\u672c\u6587\u5c06\u501f\u52a9&nbsp;<font><font><a href=\"https:\/\/github.com\/jwagner\/smartcrop.js\" name=\"smartcrop.js\" target=\"_blank\" title=\"smartcrop.js\">smartcrop.js<\/a><\/font><\/font> \u6765\u5b9e\u73b0\u4e00\u6b3e\u667a\u80fd\u56fe\u7247\u88c1\u526a\u3002\n<\/p>\n<h2>\n\tsmartcrop.js \u7b80\u4ecb<br \/>\n<\/h2>\n<p>\n\t<font><font><a href=\"https:\/\/github.com\/jwagner\/smartcrop.js\" name=\"smartcrop.js\" target=\"_blank\" title=\"smartcrop.js\">smartcrop.js<\/a><\/font><\/font> \u662f\u4e00\u6b3e\u5185\u5bb9\u611f\u77e5\u56fe\u50cf\u88c1\u526a\u63d2\u4ef6\u3002Smartcrop.js\u5b9e\u73b0\u4e86\u4e00\u79cd\u7b97\u6cd5\u6765\u67e5\u627e\u56fe\u50cf\u7684\u826f\u597d\u4f5c\u7269\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"smartcrop.js\" src=\"https:\/\/camo.githubusercontent.com\/dea304b06185f1c92225100848c68602416656db\/68747470733a2f2f3239612e63682f73616e64626f782f323031342f736d61727463726f702f6578616d706c652e6a7067\" style=\"width: 1304px;height: 404px\" \/>\n<\/p>\n<h2>\n\tsmartcrop.js&nbsp;\u7ec4\u4ef6\u7684\u539f\u7406<br \/>\n<\/h2>\n<p>\n\t<font><font><a href=\"https:\/\/github.com\/jwagner\/smartcrop.js\" name=\"smartcrop.js\" target=\"_blank\" title=\"smartcrop.js\">smartcrop.js<\/a><\/font><\/font>&nbsp;\u7ec4\u4ef6\u7684\u539f\u7406\u5927\u81f4\u662f\u6839\u636e\u989c\u8272\u9971\u548c\u5ea6\u8fdb\u884c\u8303\u56f4\u6269\u6563\u88c1\u526a\u3002\u8fd9\u662fJS\u5b9e\u73b0\u7684\u7b97\u6cd5\uff0c\u8bfb\u50cf\u7d20\u70b9\u7684\u989c\u8272\u7136\u540e\u6839\u636e\u7279\u5b9a\u7684\u7b97\u6cd5\uff08\u6bd4\u5982\u7b97\u8272\u5dee\uff0c\u6e10\u53d8\u5ea6\u7b49\uff09\u627e\u51fa\u53ef\u80fd\u662f\u91cd\u70b9\u7684\u90e8\u5206\u3002\n<\/p>\n<p>\n\t<font><font>Smartcrop.js\u4f7f\u7528\u76f8\u5f53\u611a\u8822\u7684\u56fe\u50cf\u5904\u7406\u3002<\/font><font>\u7b80\u800c\u8a00\u4e4b\uff1a<\/font><\/font>\n<\/p>\n<ol>\n<li>\n\t\t<font><font>\u4f7f\u7528laplace\u67e5\u627e\u8fb9\u7f18<\/font><\/font>\n\t<\/li>\n<li>\n\t\t<font><font>\u4f7f\u7528\u76ae\u80a4\u7b49\u989c\u8272\u67e5\u627e\u533a\u57df<\/font><\/font>\n\t<\/li>\n<li>\n\t\t<font><font>\u627e\u5230\u9971\u548c\u5ea6\u8f83\u9ad8\u7684\u533a\u57df<\/font><\/font>\n\t<\/li>\n<li>\n\t\t<font><font>\u6309\u9009\u9879\u6307\u5b9a\u7684\u533a\u57df\u63d0\u5347\u533a\u57df\uff08\u4f8b\u5982\u68c0\u6d4b\u5230\u7684\u9762\u90e8\uff09<\/font><\/font>\n\t<\/li>\n<li>\n\t\t<font><font>\u4f7f\u7528\u6ed1\u52a8\u7a97\u53e3\u751f\u6210\u4e00\u7ec4\u5019\u9009\u4f5c\u7269<\/font><\/font>\n\t<\/li>\n<li>\n\t\t<font><font>\u4f7f\u7528\u91cd\u8981\u6027\u51fd\u6570\u5bf9\u5b83\u4eec\u6392\u5e8f\uff0c\u4ee5\u5c06\u7ec6\u8282\u96c6\u4e2d\u5728\u4e2d\u5fc3\u5e76\u907f\u514d\u5b83\u5728\u8fb9\u7f18\u3002<\/font><\/font>\n\t<\/li>\n<li>\n\t\t<font><font>\u8f93\u51fa\u6700\u9ad8\u7b49\u7ea7\u7684\u5019\u9009\u4f5c\u7269<\/font><\/font>\n\t<\/li>\n<\/ol>\n<h2>\n\t\u5b89\u88c5<br \/>\n<\/h2>\n<p>\n\t\u4f7f\u7528 npm \u547d\u4ee4\u5b89\u88c5\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\nnpm install smartcrop<\/pre>\n<p>\n\t\u6216\u8005\u76f4\u63a5\u4ece git \u4ed3\u5e93\u4e2d\u4e0b\u8f7d&nbsp;<a href=\"https:\/\/raw.githubusercontent.com\/jwagner\/smartcrop.js\/master\/smartcrop.js\" name=\"smartcrop.js\" rel=\"nofollow\" target=\"_blank\" title=\"smartcrop.js\">smartcrop.js<\/a>\u3002\n<\/p>\n<p>\n\t\u57fa\u672c\u7528\u6cd5\n<\/p>\n<pre class=\"brush:jscript;\">\r\n\/\/ you pass in an image as well as the width &amp; height of the crop you\r\n\/\/ want to optimize.\r\nsmartcrop.crop(image, { width: 100, height: 100 }).then(function(result) {\r\n  console.log(result);\r\n});<\/pre>\n<pre class=\"brush:jscript;\">\r\nSmartCrop.crop(image, {\r\n\twidth: 100,\r\n\theight: 100\r\n}, \r\nfunction(result){\r\n\tconsole.log(result); \/\/ {topCrop: {x: 300, y: 200, height: 200, width: 200}}\r\n});<\/pre>\n<p>\n\t\u5b83\u4f1a\u8f93\u51fa\u4e00\u4e2a\u6bd4\u8f83\u597d\u7684\u6700\u4f73\u56fe\u7247\u88c1\u526a\u4f4d\u7f6e\uff0c\u5982{topCrop: {x: 300, y: 200, height: 200, width: 200}}\u7684\u6570\u636e\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"smartcrop.js\" src=\"http:\/\/greengerong.github.io\/images\/blog_img\/smartcrop-%E5%9B%BE%E7%89%87%E8%A3%81%E5%89%AA-%E6%A1%88%E4%BE%8B.png\" style=\"width: 600px;height: 365px\" \/>\n<\/p>\n<p>\n\t<font><font><a href=\"https:\/\/github.com\/jwagner\/smartcrop-cli\">smartcrop-CLI<\/a>&nbsp;\u5de5\u5177<\/font><\/font><font><font>\u63d0\u4f9b\u4e86\u4f7f\u7528\u547d\u4ee4\u884c\u6765\u64cd\u4f5c <a href=\"https:\/\/github.com\/jwagner\/smartcrop.js\" name=\"smartcrop.js\" target=\"_blank\" title=\"smartcrop.js\">smartcrop.js<\/a>\u3002<\/font><\/font>\n<\/p>\n<p>\n\t<font><font>\u60a8\u53ef\u4ee5\u901a\u8fc7<\/font><\/font><a href=\"https:\/\/github.com\/jwagner\/smartcrop-gm\"><font><font>smartcrop-gm<\/font><\/font><\/a><font><font>\uff08\u901a\u8fc7gm\u4f7f\u7528\u56fe\u50cfmagick\uff09\u6216<\/font><\/font><a href=\"https:\/\/github.com\/jwagner\/smartcrop-sharp\"><font><font>smartcrop-sharp<\/font><\/font><\/a><font><font>\uff08\u901a\u8fc7sharp\u4f7f\u7528libvips\uff09\u4ecenodejs\u4f7f\u7528smartcrop\u3002<\/font><\/font>\n<\/p>\n<p>\n\t\u6700\u540e\uff0c\u66f4\u591a\u5173\u4e8e <font><font><a href=\"https:\/\/github.com\/jwagner\/smartcrop.js\" name=\"smartcrop.js\" target=\"_blank\" title=\"smartcrop.js\">smartcrop.js<\/a>&nbsp;<\/font><\/font>\u7684\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1\u5176 github\uff1a<a href=\"https:\/\/github.com\/jwagner\/smartcrop.js\">https:\/\/github.com\/jwagner\/smartcrop.js<\/a>\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2536\">HTML5 \u5b9e\u73b0 alarm \u58c1\u7eb8\u7684\u526a\u88c1(smartcrop.js \u6559\u7a0b)<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>HTML5 \u5f88\u5f3a\u5927\uff0c\u6216\u8005\u8bf4 JavaScript \u7f16\u7a0b\u8bed\u8a00\u5f88\u5f3a\u5927\uff0c\u5b83\u4eec\u80fd\u5728\u7f51\u9875\u4e0a\u5b9e\u73b0\u667a\u80fd\u526a\u88c1\u3002\u5236\u4f5c\u5404\u79cd\u5404\u6837\u7684\u58c1 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[814,119,1106,337,1301],"class_list":["post-2536","post","type-post","status-publish","format-standard","hentry","category-html5","tag-css3","tag-html5","tag-javascript","tag-javascriptapi","tag-1301"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2536"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2536\/revisions"}],"predecessor-version":[{"id":2537,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2536\/revisions\/2537"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}