{"id":6006,"date":"2017-03-09T00:42:27","date_gmt":"2017-03-08T16:42:27","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6006"},"modified":"2017-03-09T00:46:48","modified_gmt":"2017-03-08T16:46:48","slug":"transparent-jpg-svg","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2017\/03\/transparent-jpg-svg\/","title":{"rendered":"\u3010\u7ffb\u8bd1\u3011\u501f\u52a9SVG\u5b9e\u73b0\u80cc\u666f\u900f\u660eJPG\u56fe\u7247"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6006\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=6006<\/a><br \/>\n\u672c\u6587\u7ffb\u8bd1\u81ea\uff1a<a href=\"https:\/\/css-tricks.com\/transparent-jpg-svg\/\" target=\"_blank\" rel=\"nofollow\">https:\/\/css-tricks.com\/transparent-jpg-svg\/<\/a><br \/>\n\u672c\u6587\u53ef\u5168\u6587\u8f6c\u8f7d\uff0c\u4f46\u9700\u5f97\u5230\u539f\u4f5c\u8005\u4e66\u9762\u8bb8\u53ef\uff0c\u540c\u65f6\u4fdd\u7559\u539f\u4f5c\u8005\u548c\u51fa\u5904\uff0c\u6458\u8981\u5f15\u6d41\u5219\u968f\u610f\u3002<\/p>\n<p>\u53cb\u60c5\u63d0\u9192\uff0c\u6280\u672f\u76f8\u5173\u4ee5\u4e3a\u8a00\u8bba\u4ec5\u4f9b\u53c2\u8003\u3002<\/p>\n<div style=\"padding:3px; background-color:#eee;\">\n<div style=\"border:1px solid #cacaca;\">\n<div style=\"background-color:#eee; padding:10px; background-image:linear-gradient(#FAFAFA, #EAEAEA);\">\u7ffb\u8bd1\u6b63\u6587<\/div>\n<div style=\"padding:20px; background-color:#fff;\">\n<p>\u6211\u662f\u4e2a\u5bf9\u81ea\u5df1\u989c\u503c\u5f88\u81ea\u4fe1\u7684\u4eba\uff0c\u6bcf\u5929\u53eb\u9192\u6211\u8d77\u5e8a\u7684\u4e0d\u662f\u95f9\u949f\uff0c\u4e5f\u4e0d\u662f\u68a6\u60f3\uff0c\u800c\u662f\u81ea\u5df1\u7684\u989c\u503c\uff0c\u6bcf\u6bcf\u60f3\u5230\u6211\u957f\u5f97\u5982\u6b64\u4fca\u4fcf\uff0c\u90fd\u4f1a\u4ece\u68a6\u4e2d\u7b11\u9192\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u4eba\u5728\u6c5f\u6e56\u98d8\uff0c\u54ea\u6709\u4e0d\u6328\u5200\u3002<\/p>\n<p>\u7ecf\u5e38\u51fa\u5165\u4e00\u4e9b\u793e\u4ea4\u573a\u5408\uff0c\u96be\u514d\u548c\u548c\u5176\u4ed6\u7684\u4eba\u548c\u7269\u4e00\u8d77\u7167\u4e2a\u76f8\u4ec0\u4e48\u7684\u3002<\/p>\n<p>\u5982\u679c\u548c\u6211\u5408\u5f71\u7684\u662f\u8fea\u4e3d\u70ed\u5df4\u8fd9\u6837\u7684\u7f8e\u5973\u4e5f\u5c31\u7b97\u4e86\uff0c\u4f46\u7ecf\u5e38\u5728\u6211\u5de6\u53f3\u7684\u90fd\u662f\u5927\u8001\u7237\u4eec\uff0c\u6709\u65f6\u5019\uff0c\u751a\u81f3\u8fd8\u6709\u5176\u4ed6\u5b8c\u5168\u4e0d\u77e5\u5f62\u8c61\u4e3a\u4f55\u7269\u7684\u6c6a\u79d1\u7269\u79cd\uff0c\u6b64\u65f6\u6211\u591a\u5e0c\u671b\u7167\u7247\u4e2d\u5c31\u6211\u4e00\u4e2a\u4eba\uff0c\u5c31\u50cf\u4e0b\u9762\u8fd9\u6837\uff0c\u53ea\u6709\u4e00\u4e2a\u7f8e\u7f8e\u7684\u6211\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201703\/orig.jpg\" width=\"500\" height=\"353\" alt=\"\u7f8e\u7f8e\u7684\u6211\" class=\"alignnone\" \/><\/p>\n<p>\u8be5\u6b7b\uff0c\u76f4\u63a5\u6846\u4e2a\u6846\u540e\u9762\u8fd8\u9732\u51fa\u4e86\u4e00\u53cc\u624b\uff0c\u53f3\u4fa7\u8fd8\u6709\u534a\u4e2a\u6c6a\u661f\u4eba\u7684\u8eab\u5b50\uff0c\u5b8c\u5168\u5c31\u662f\u9ebb\u5b50\u7684\u8138\u2014\u2014\u6ee1\u662f\u7f3a\u70b9\u4e86\u561b\u3002<\/p>\n<p>\u597d\u5728\u6211\u548c\u5916\u9762\u90a3\u4e9b\u53ea\u4f1a\u7528\u7f8e\u56fe\u79c0\u79c0\u7684\u82b8\u82b8\u7c89\u9edb\u4e0d\u4e00\u6837\uff0c\u6211\u4f1a\u771f\u6b63\u7684PS\u6280\u672f\uff0c\u770b\u6211\uff0c\u94a2\u7b14\u5de5\u5177\u73a9\u5f97\u6e9c\u6e9c\u7684\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201703\/clip-path.jpg\" width=\"500\" height=\"466\" alt=\"\u94a2\u7b14\u62a0\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u628a\u6211\u7f8e\u597d\u5f62\u8c61\u5916\u7684\u5176\u4ed6\u90fd\u662f\u90fd\u62a0\u56fe\u6263\u6389\uff0c\u554a\u54c8\uff0c\u987f\u65f6\u4e16\u754c\u5c31\u6e05\u723d\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201703\/too-big.jpg\" width=\"500\" height=\"397\" alt=\"png\u62a0\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u4f46\u662f\uff0c\u6211\u53d1\u73b0\u4e86\u4e00\u4ef6\u4e0d\u592a\u5999\u7684\u4e8b\u60c5\uff0c\u8fd9\u5de6\u4e0b\u89d2\u663e\u793a\u7684PNG-24\u7684\u5c3a\u5bf8-<strong>1013k<\/strong>\uff0c\u6211\u53bb\uff0c\u90a3\u5c31\u51e0\u4e4e\u5c31\u662f1M\u4e86\u554a\uff0c\u867d\u7136\u8bf4\u73b0\u5728\u53d6\u6d88\u4e86\u6f2b\u6e38\u8d39\uff0c\u4f46\u662f\u8fd9\u4e2a\u6d41\u91cf\u4e00\u70b9\u5173\u7cfb\u90fd\u6ca1\u6709\u554a\uff0c\u518d\u7f8e\u7684\u7167\u7247\u5982\u679c\u52a0\u8f7d\u4e0d\u51fa\u6765\u4e5f\u662f\u767d\u642d\u554a\u3002<\/p>\n<p>\u4e0d\u6025\uff0c\u8fd8\u6709\u4e00\u79cdPNG-8\u683c\u5f0f\uff0c\u5c3a\u5bf8\u5e94\u8be5\u53ef\u4ee5\u5c0f\u4e00\u70b9\uff0c\u679c\u4e0d\u5176\u7136\uff0c\u5c11\u4e86\u5dee\u4e0d\u591a75%\uff0c\u5389\u5bb3\u4e86\u6211\u7684\u56fe\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201703\/png8.jpg\" width=\"500\" height=\"395\" alt=\"PNG8\u56fe\u7247\u5927\u5c0f\" class=\"alignnone\" \/><\/p>\n<p>\u4f46\u662f\uff0c\u8fd9\u6bdb\u5230\u5929\u9645\u7684\u6548\u679c\u662f\u600e\u4e48\u56de\u4e8b\uff1fOh, No! \u8fd9\u95ee\u9898\u53ef\u6bd4\u56fe\u7247\u5c3a\u5bf8\u5927\u4e25\u91cd\u591a\u4e86\uff0c\u6211\u5b81\u53ef\u663e\u793a\u6162\u4e5f\u4e0d\u8981\u663e\u793a\u51fa\u6765\u4e00\u526f\u9ebb\u5b50\u8138\u3002<\/p>\n<p>\u5982\u679c\u6211\u4fdd\u5b58\u4e3aJPG\u683c\u5f0f\u5462\uff1f\u5594\u5662\uff0c\u5c3a\u5bf8\u66f4\u68d2\u68d2\u54d2~<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201703\/jpg.jpg\" width=\"500\" height=\"343\" alt=\"JPEG\u683c\u5f0f\u7684\u5c3a\u5bf8\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u4f46\u662f\uff0c\u80cc\u666f\u4e0d\u662f\u900f\u660e\u7684\uff0c\u4e0d\u5c31\u610f\u5473\u7740\u6211\u53ea\u80fd\u5047\u88c5\u5728\u96ea\u5c71\u5ea6\u5047\u5417\uff1fOh, No! \u5929\u8981\u7edd\u6211\u5417\uff0c\u8bf7\u8ba9\u6211\u54ed\u4e00\u4f1a\u513f~<\/p>\n<p>\u6162\u7740\uff0c\u6211\u7a81\u7136\u7075\u5149\u4e00\u95ea\uff01\u6211\u4eec\u662f\u4e0d\u662f\u53ef\u4ee5\u4f7f\u7528\u4ee3\u7801\u6a21\u62df\u94a2\u7b14\u8def\u5f84\u7684\u526a\u88c1\u6548\u679c\u5462\uff1f\u6bd4\u65b9\u8bf4\u4f7f\u7528\u524d\u9762<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?s=clip-path\" target=\"_blank\">\u591a\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u8fc7\u7684clip-path\u5c5e\u6027<\/a>\uff0c\u867d\u7136\u8bf4\u73b0\u5728CSS\u53ea\u652f\u6301\u591a\u8fb9\u5f62\u526a\u88c1\uff0c\u8fd8\u4e0d\u652f\u6301\u4efb\u610f\u8def\u5f84\u7684\u526a\u88c1\uff0c\u4f46\u662f\u73b0\u5728\u524d\u7aef\u65b0\u5ba0SVG\u652f\u6301\u554a\uff01<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4e0b\u9762\u8fd9\u4e24\u6837\u4e1c\u897f\u5c31\u53ef\u4ee5\u5f97\u5230\u5c3a\u5bf8\u5c0f\u800c\u7f8e\u9753\u7167\u4e86\uff1a<\/p>\n<ol>\n<li>JPG\u56fe\u7247<\/li>\n<li>\u526a\u88c1\u8def\u5f84<\/li>\n<\/ol>\n<p>\u7b2c\u4e00\u6b65\uff0c\u56fe\u7247SVG\u8f7d\u5165\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>&lt;svg&gt;\n  &lt;image xlink:href=\"\/images\/chris.jpg\" x=\"0\" y=\"0\"&gt;\n&lt;svg&gt;<\/pre>\n<p>\u7b2c\u4e8c\u6b65\uff0c\u628a\u521a\u521a\u4f7f\u7528\u94a2\u7b14\u5de5\u5177\u5728\u52fe\u52d2\u7684\u8def\u5f84\u5bfc\u51fa\u5230Illustrator\u4e2d\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201703\/paths-to-illustrator.jpg\" width=\"500\" height=\"328\" alt=\"\u8def\u5f84\u5bfc\u51fa\" class=\"alignnone\" \/><\/p>\n<p>\u6b64\u65f6\uff0c\u6211\u4eec\u5c31\u6709\u4e86\u8def\u5f84\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u8f7b\u677e\u5bfc\u51fa\u4e3aSVG\u5566\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201703\/clip-from-ai.jpg\" width=\"500\" height=\"473\" alt=\"AI\u4e2d\u7684\u8def\u5f84\u793a\u610f\" class=\"alignnone\" \/><\/p>\n<p>\u5bfc\u51fa\u7684\u8def\u5f84\u4ee3\u7801\u793a\u610f\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201703\/path-data.png\" width=\"500\" height=\"195\" alt=\"\u5bfc\u51fa\u7684\u8def\u5f84\u4ee3\u7801\u793a\u610f\" class=\"alignnone\" \/><\/p>\n<p>\u7136\u540e\uff0c\u5728SVG\u4e2d\u4f7f\u7528<code>&lt;path&gt;<\/code>\u4f5c\u4e3a\u68c0\u67e5\u8def\u5f84\uff0c\u653e\u5728<code>&lt;clipPath&gt;<\/code>\u4e2d\uff0c\u540c\u65f6\uff0c\u5c06\u6b64\u526a\u88c1\u8def\u5f84\u5e94\u7528\u5230\u6211\u4eec\u7684<code>&lt;image&gt;<\/code>\u5143\u7d20\u4e0a\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>&lt;svg viewBox=\"0 0 921.17 1409.71\"&gt;\n  &lt;defs&gt;\n    &lt;clipPath id=\"chris-clip\"&gt;\n      &lt;path d=\" ... \" \/&gt;\n    &lt;\/clipPath&gt;\n  &lt;\/defs&gt;\n  &lt;image xlink:href=\"\/images\/chris.jpg\" clip-path=\"url(#chris-clip)\" x=\"0\" y=\"0\" width=\"921\" height=\"1409\"&gt;\n&lt;svg&gt;<\/pre>\n<p>\u7ed3\u679c\uff0c\u5f53\u5f53\u5f53\u5f53~~<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/wx2.sinaimg.cn\/mw690\/4b4d632fgy1fdfvax1hl7g208w06z11v.gif\" width=\"320\" height=\"251\" alt=\"\u6700\u7ec8\u7684\u6548\u679cgif\u6f14\u793a\" class=\"alignnone\" \/><\/p>\n<p>\u5728\u4efb\u4f55\u80cc\u666f\u4e0b\u90fd\u7f8e\u7f8e\u7684\u6211\u5c31\u8fd9\u6837\u51fa\u6765\u4e86\u3002<\/p>\n<p>\u5509\uff0c\u660e\u65e9\u53c8\u662f\u6ce8\u5b9a\u8981\u88ab\u5e05\u9192\u7684\u4e00\u5929\uff0c\u771f\u662f\u6ca1\u529e\u6cd5\u3002<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201703\/timg.png\" width=\"150\" height=\"167\" alt=\"\u554a~\u53c8\u88ab\u81ea\u5df1\u5e05\u9192\" class=\"alignnone\" \/><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=6006\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=6006<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eba\u7269\u5f80\u5f80\u8272\u5f69\u4e30\u5bcc\uff0c\u6709\u65f6\u5019\u4f1a\u9047\u5230\u9700\u8981\u80cc\u666f\u900f\u660e\u7684\u573a\u666f\uff0c\u7ed3\u679cPNG24\u56fe\u7247\u5c3a\u5bf8\u592a\u5927\uff0cPNG8\u8d28\u91cf\u592a\u5dee\uff0cJPG\u5c3a\u5bf8\u6700\u5c0f\u6548\u679c\u8fd8\u597d\uff0c\u4f46\u662f\u80cc\u666f\u53c8\u4e0d\u900f\u660e\uff0c\u6709\u6ca1\u6709\u4ec0\u4e48\u529e\u6cd5\u5c31\u6709JPG\u7684\u5c0f\u5c3a\u5bf8\u597d\u6548\u679c\uff0c\u540c\u65f6\u80cc\u666f\u900f\u660e\u5462\uff1f\u672c\u6587\u7684\u5904\u7406\u6280\u5de7\u53ef\u80fd\u4f1a\u5bf9\u4f60\u89e3\u51b3\u76f8\u5173\u95ee\u9898\u63d0\u4f9b\u4e00\u4e9b\u601d\u8def\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[895,198],"tags":[959,10,12,642,919,25],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/6006"}],"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=6006"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/6006\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=6006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=6006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=6006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}