{"id":172664,"date":"2020-10-26T05:53:05","date_gmt":"2020-10-25T21:53:05","guid":{"rendered":"http:\/\/4563.org\/?p=172664"},"modified":"2020-10-26T05:53:05","modified_gmt":"2020-10-25T21:53:05","slug":"python-%e5%86%85%e5%ad%98%e9%97%ae%e9%a2%98%e6%b1%82%e6%95%99","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=172664","title":{"rendered":"Python \u5185\u5b58\u95ee\u9898\u6c42\u6559"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Python \u5185\u5b58\u95ee\u9898\u6c42\u6559               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JCZ2MkKb5S8ZX9pq <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code># \u4f2a\u4ee3\u7801 from psd_tools import PSDImage  def main():     for file in file_list:         save_jpg(file)          def save_jpg(file):     img = PSDImage.open(file).composite()     img.save(output_name) <\/code><\/pre>\n<ul>\n<li>\u60f3\u8981\u6279\u91cf\u7ed9 psd \u5bfc\u51fa\u7f29\u7565\u56fe\uff08 PS actions \u6211\u4f1a\u7684\uff0c\u6211\u53ea\u662f\u7b80\u5316\u8bf4\u660e\uff0c\u5176\u5b9e\u8981\u505a\u4e0d\u5c11\u5176\u4ed6\u64cd\u4f5c\uff0c\u6240\u4ee5\u60f3\u7528 python \uff09\u3002<\/li>\n<li>\u73b0\u5728\u7684\u95ee\u9898\u662f\uff0c\u5982\u679c\u6bcf\u6b21\u53ea\u64cd\u4f5c\u4e00\u4e2a\u6587\u4ef6(\u505a\u4e00\u6b21<code>save_jpg<\/code>)\uff0c\u8fd0\u884c\u6b63\u5e38\u3002<\/li>\n<li>\u4f46\u5982\u679c\u628a\u540c\u4e00\u4e2a psd \u590d\u5236\u591a\u4efd\uff0c\u7136\u540e\u8fd0\u884c main \u7684\u8bdd\uff0c\u5185\u5b58\u5c31\u4f1a\u51fa\u9519\u3002\u75c7\u72b6\u662f\u7b2c\u4e00\u4e2a\u6587\u4ef6\u6b63\u5e38\u5f00\u542f\uff0c\u7b2c\u4e8c\u4e2a\u5f00\u59cb\u5185\u5b58\u5c31\u4e0d\u8db3\u4e86\u3002<\/li>\n<li>\u641e\u4e0d\u6e05\u695a\u8fd9\u4e2a\u5185\u5b58\u7ba1\u7406\u662f\u548b\u56de\u4e8b\u513f\u3002\u8bd5\u4e86\u5728<code>save_jpg<\/code>\u91cc<code>del img<\/code>\u5565\u7684\u4e5f\u6ca1\u4ec0\u4e48\u7528\uff0c\u6211\u611f\u89c9<code>save_jpg<\/code>\u8fd0\u884c\u5b8c\u4e00\u6b21\u5e94\u8be5\u5c31\u91ca\u653e\u5185\u5b58\u4e86\u3002\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u4f9d\u8d56\u5e93\u6709\u95ee\u9898\uff0c\u4f46\u6709\u4e9b psd \u76f4\u63a5\u7528 PIL.Image \u6253\u4e0d\u5f00\uff0c\u624d\u7528\u5230\u7684\u8fd9\u4e2a\u7b2c\u4e09\u65b9\u5e93\u3002<\/li>\n<\/ul>\n<ul>\n<li>\u521a\u624d\u53c8\u89c2\u5bdf\u4e86\u4e00\u4e0b\uff0c\u5176\u5b9e\u8fd0\u884c\u65f6\u5185\u5b58\u7528\u91cf\u5e76\u4e0d\u9ad8\uff0c\u90a3\u53ef\u80fd\u8fd8\u662f\u8fd9\u4e2a\u5e93\u7684\u95ee\u9898\uff1f<\/li>\n<\/ul><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3798017\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sss495088732 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u6e90\u7801\u6709\u6ca1\u6709\u91ca\u653e\u53e5\u67c4                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3798018\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xchaoinfo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             with PSDImage.open                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3798019\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ipwx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1. \u8bf7\u53ca\u65f6\u5173\u95ed\u4e0d\u9700\u8981\u7684\u4e1c\u897f\u3002<br \/>2. 32 \u4f4d\u7a0b\u5e8f\u53ea\u80fd\u7528 2GB \u7528\u6237\u6001\u5185\u5b58\u3002\u8bf7\u786e\u4fe1\u4f60\u7528\u7684\u4e0d\u662f 32 \u4f4d python \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3798020\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : laike9m <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u9700\u8981\u7684\u4e0d\u662f\u731c\u6d4b\uff0c\u800c\u662f profiling\uff0c\u63a8\u8350\u51e0\u4e2a\u5e93\u5427\uff1a<br \/>https:\/\/github.com\/pythonprofilers\/memory_profiler<br \/>https:\/\/mg.pov.lt\/objgraph\/                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3798021\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nonduality <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5047\u5982\u4f60\u5c1d\u8bd5\u8fd9\u4e48\u5199\u5462\uff1f<\/p>\n<p>&#8220;`python<br \/>def save_jpg(file):<br \/> fd = PSDImage.open(file)<br \/> fd.composite().save(output_name)<br \/> fd.close()<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Python \u5185\u5b58\u95ee\u9898\u6c42\u6559 \u8cc7\u6df1\u5927&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/172664"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=172664"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/172664\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=172664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=172664"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=172664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}