{"id":1165722,"date":"2025-01-15T15:23:52","date_gmt":"2025-01-15T07:23:52","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1165722.html"},"modified":"2025-01-15T15:23:54","modified_gmt":"2025-01-15T07:23:54","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8python%e4%b8%ad%e6%b7%bb%e5%8a%a0%e5%9b%be%e7%89%87","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1165722.html","title":{"rendered":"\u5982\u4f55\u5728python\u4e2d\u6dfb\u52a0\u56fe\u7247"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25210009\/d343dd38-c73d-4583-a925-d7837367dd2a.webp\" alt=\"\u5982\u4f55\u5728python\u4e2d\u6dfb\u52a0\u56fe\u7247\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u6dfb\u52a0\u56fe\u7247\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec<strong>\u4f7f\u7528PIL\u5e93\u3001\u4f7f\u7528OpenCV\u5e93\u3001\u4f7f\u7528Matplotlib\u5e93<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528PIL\u5e93\u662f\u6700\u5e38\u89c1\u548c\u7b80\u4fbf\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528PIL\u5e93\u6765\u6dfb\u52a0\u56fe\u7247\u3002<\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528PIL\u5e93<\/strong><\/p>\n<\/p>\n<p><p>PIL\uff08Python Imaging Library\uff09\u662fPython\u4e2d\u4e00\u4e2a\u5f3a\u5927\u7684\u56fe\u50cf\u5904\u7406\u5e93\u3002\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u56fe\u50cf\u64cd\u4f5c\u529f\u80fd\uff0c\u5982\u6253\u5f00\u3001\u64cd\u4f5c\u3001\u4fdd\u5b58\u56fe\u50cf\u7b49\u3002\u8981\u4f7f\u7528PIL\u5e93\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Pillow\uff0c\u8fd9\u662fPIL\u7684\u4e00\u4e2a\u5206\u652f\u5e76\u4e14\u4fdd\u6301\u66f4\u65b0\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5Pillow<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528PIL\u5e93\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Pillow\u5e93\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install Pillow<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u6253\u5f00\u5e76\u663e\u793a\u56fe\u7247<\/h3>\n<\/p>\n<p><p>\u5728\u5b89\u88c5Pillow\u5e93\u4e4b\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u6765\u6253\u5f00\u5e76\u663e\u793a\u56fe\u7247\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image<\/p>\n<h2><strong>\u6253\u5f00\u56fe\u7247<\/strong><\/h2>\n<p>image = Image.open(&#39;path_to_image.jpg&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u7247<\/strong><\/h2>\n<p>image.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>Image.open<\/code>\u51fd\u6570\u7528\u4e8e\u6253\u5f00\u6307\u5b9a\u8def\u5f84\u7684\u56fe\u7247\uff0c\u800c<code>image.show<\/code>\u51fd\u6570\u7528\u4e8e\u663e\u793a\u56fe\u7247\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u5728\u56fe\u7247\u4e0a\u6dfb\u52a0\u6587\u5b57<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u6253\u5f00\u548c\u663e\u793a\u56fe\u7247\uff0cPillow\u8fd8\u63d0\u4f9b\u4e86\u5728\u56fe\u7247\u4e0a\u6dfb\u52a0\u6587\u5b57\u7684\u529f\u80fd\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5728\u56fe\u7247\u4e0a\u6dfb\u52a0\u6587\u5b57\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image, ImageDraw, ImageFont<\/p>\n<h2><strong>\u6253\u5f00\u56fe\u7247<\/strong><\/h2>\n<p>image = Image.open(&#39;path_to_image.jpg&#39;)<\/p>\n<h2><strong>\u521b\u5efa\u7ed8\u56fe\u5bf9\u8c61<\/strong><\/h2>\n<p>draw = ImageDraw.Draw(image)<\/p>\n<h2><strong>\u5b9a\u4e49\u6587\u5b57\u548c\u5b57\u4f53<\/strong><\/h2>\n<p>text = &quot;Hello, World!&quot;<\/p>\n<p>font = ImageFont.truetype(&#39;arial.ttf&#39;, 36)<\/p>\n<h2><strong>\u6dfb\u52a0\u6587\u5b57\u5230\u56fe\u7247<\/strong><\/h2>\n<p>draw.text((10, 10), text, font=font, fill=(255, 255, 255))<\/p>\n<h2><strong>\u663e\u793a\u56fe\u7247<\/strong><\/h2>\n<p>image.show()<\/p>\n<h2><strong>\u4fdd\u5b58\u56fe\u7247<\/strong><\/h2>\n<p>image.save(&#39;output_image.jpg&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>ImageDraw.Draw<\/code>\u51fd\u6570\u7528\u4e8e\u521b\u5efa\u7ed8\u56fe\u5bf9\u8c61\uff0c<code>ImageFont.truetype<\/code>\u51fd\u6570\u7528\u4e8e\u5b9a\u4e49\u5b57\u4f53\u3002<code>draw.text<\/code>\u51fd\u6570\u7528\u4e8e\u5728\u6307\u5b9a\u4f4d\u7f6e\u6dfb\u52a0\u6587\u5b57\uff0c\u5e76\u6307\u5b9a\u6587\u5b57\u7684\u989c\u8272\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5728\u56fe\u7247\u4e0a\u6dfb\u52a0\u56fe\u5f62<\/h3>\n<\/p>\n<p><p>\u9664\u4e86\u6dfb\u52a0\u6587\u5b57\uff0c\u8fd8\u53ef\u4ee5\u5728\u56fe\u7247\u4e0a\u6dfb\u52a0\u56fe\u5f62\uff0c\u5982\u77e9\u5f62\u3001\u5706\u5f62\u7b49\u3002\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u5728\u56fe\u7247\u4e0a\u6dfb\u52a0\u77e9\u5f62\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image, ImageDraw<\/p>\n<h2><strong>\u6253\u5f00\u56fe\u7247<\/strong><\/h2>\n<p>image = Image.open(&#39;path_to_image.jpg&#39;)<\/p>\n<h2><strong>\u521b\u5efa\u7ed8\u56fe\u5bf9\u8c61<\/strong><\/h2>\n<p>draw = ImageDraw.Draw(image)<\/p>\n<h2><strong>\u6dfb\u52a0\u77e9\u5f62\u5230\u56fe\u7247<\/strong><\/h2>\n<p>draw.rectangle([(50, 50), (150, 150)], outline=&quot;red&quot;, width=5)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u7247<\/strong><\/h2>\n<p>image.show()<\/p>\n<h2><strong>\u4fdd\u5b58\u56fe\u7247<\/strong><\/h2>\n<p>image.save(&#39;output_image_with_rectangle.jpg&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>draw.rectangle<\/code>\u51fd\u6570\u7528\u4e8e\u5728\u56fe\u7247\u4e0a\u6dfb\u52a0\u77e9\u5f62\uff0c\u5e76\u6307\u5b9a\u77e9\u5f62\u7684\u8fb9\u6846\u989c\u8272\u548c\u5bbd\u5ea6\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u56fe\u50cf\u5408\u6210<\/h3>\n<\/p>\n<p><p>Pillow\u8fd8\u63d0\u4f9b\u4e86\u56fe\u50cf\u5408\u6210\u529f\u80fd\uff0c\u53ef\u4ee5\u5c06\u4e24\u5f20\u56fe\u7247\u5408\u6210\u4e00\u5f20\u3002\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u8fdb\u884c\u56fe\u50cf\u5408\u6210\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image<\/p>\n<h2><strong>\u6253\u5f00\u4e24\u5f20\u56fe\u7247<\/strong><\/h2>\n<p>image1 = Image.open(&#39;path_to_image1.jpg&#39;)<\/p>\n<p>image2 = Image.open(&#39;path_to_image2.jpg&#39;)<\/p>\n<h2><strong>\u8c03\u6574\u7b2c\u4e8c\u5f20\u56fe\u7247\u7684\u5927\u5c0f<\/strong><\/h2>\n<p>image2 = image2.resize((100, 100))<\/p>\n<h2><strong>\u5408\u6210\u56fe\u7247<\/strong><\/h2>\n<p>image1.paste(image2, (50, 50))<\/p>\n<h2><strong>\u663e\u793a\u5408\u6210\u540e\u7684\u56fe\u7247<\/strong><\/h2>\n<p>image1.show()<\/p>\n<h2><strong>\u4fdd\u5b58\u5408\u6210\u540e\u7684\u56fe\u7247<\/strong><\/h2>\n<p>image1.save(&#39;output_image_composite.jpg&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>image1.paste<\/code>\u51fd\u6570\u7528\u4e8e\u5c06\u7b2c\u4e8c\u5f20\u56fe\u7247\u7c98\u8d34\u5230\u7b2c\u4e00\u5f20\u56fe\u7247\u7684\u6307\u5b9a\u4f4d\u7f6e\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u8c03\u6574\u56fe\u7247<\/h3>\n<\/p>\n<p><p>Pillow\u8fd8\u63d0\u4f9b\u4e86\u8c03\u6574\u56fe\u7247\u5927\u5c0f\u3001\u65cb\u8f6c\u56fe\u7247\u3001\u88c1\u526a\u56fe\u7247\u7b49\u529f\u80fd\u3002\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u8c03\u6574\u56fe\u7247\u5927\u5c0f\u3001\u65cb\u8f6c\u548c\u88c1\u526a\u56fe\u7247\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image<\/p>\n<h2><strong>\u6253\u5f00\u56fe\u7247<\/strong><\/h2>\n<p>image = Image.open(&#39;path_to_image.jpg&#39;)<\/p>\n<h2><strong>\u8c03\u6574\u56fe\u7247\u5927\u5c0f<\/strong><\/h2>\n<p>resized_image = image.resize((200, 200))<\/p>\n<h2><strong>\u65cb\u8f6c\u56fe\u7247<\/strong><\/h2>\n<p>rotated_image = image.rotate(45)<\/p>\n<h2><strong>\u88c1\u526a\u56fe\u7247<\/strong><\/h2>\n<p>cropped_image = image.crop((50, 50, 200, 200))<\/p>\n<h2><strong>\u663e\u793a\u8c03\u6574\u540e\u7684\u56fe\u7247<\/strong><\/h2>\n<p>resized_image.show()<\/p>\n<p>rotated_image.show()<\/p>\n<p>cropped_image.show()<\/p>\n<h2><strong>\u4fdd\u5b58\u8c03\u6574\u540e\u7684\u56fe\u7247<\/strong><\/h2>\n<p>resized_image.save(&#39;resized_image.jpg&#39;)<\/p>\n<p>rotated_image.save(&#39;rotated_image.jpg&#39;)<\/p>\n<p>cropped_image.save(&#39;cropped_image.jpg&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>image.resize<\/code>\u51fd\u6570\u7528\u4e8e\u8c03\u6574\u56fe\u7247\u5927\u5c0f\uff0c<code>image.rotate<\/code>\u51fd\u6570\u7528\u4e8e\u65cb\u8f6c\u56fe\u7247\uff0c<code>image.crop<\/code>\u51fd\u6570\u7528\u4e8e\u88c1\u526a\u56fe\u7247\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u4f7f\u7528OpenCV\u5e93<\/h3>\n<\/p>\n<p><p>OpenCV\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u8ba1\u7b97\u673a\u89c6\u89c9\u5e93\uff0c\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u56fe\u50cf\u5904\u7406\u529f\u80fd\u3002\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528OpenCV\u6253\u5f00\u5e76\u663e\u793a\u56fe\u7247\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import cv2<\/p>\n<h2><strong>\u6253\u5f00\u56fe\u7247<\/strong><\/h2>\n<p>image = cv2.imread(&#39;path_to_image.jpg&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u7247<\/strong><\/h2>\n<p>cv2.imshow(&#39;Image&#39;, image)<\/p>\n<p>cv2.w<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>tKey(0)<\/p>\n<p>cv2.destroyAllWindows()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>cv2.imread<\/code>\u51fd\u6570\u7528\u4e8e\u6253\u5f00\u6307\u5b9a\u8def\u5f84\u7684\u56fe\u7247\uff0c<code>cv2.imshow<\/code>\u51fd\u6570\u7528\u4e8e\u663e\u793a\u56fe\u7247\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u4f7f\u7528Matplotlib\u5e93<\/h3>\n<\/p>\n<p><p>Matplotlib\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u7ed8\u56fe\u5e93\uff0c\u901a\u5e38\u7528\u4e8e\u7ed8\u5236\u56fe\u8868\uff0c\u4f46\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5904\u7406\u56fe\u50cf\u3002\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Matplotlib\u6253\u5f00\u5e76\u663e\u793a\u56fe\u7247\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>import matplotlib.image as mpimg<\/p>\n<h2><strong>\u6253\u5f00\u56fe\u7247<\/strong><\/h2>\n<p>image = mpimg.imread(&#39;path_to_image.jpg&#39;)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u7247<\/strong><\/h2>\n<p>plt.imshow(image)<\/p>\n<p>plt.axis(&#39;off&#39;)  # \u5173\u95ed\u5750\u6807\u8f74<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>mpimg.imread<\/code>\u51fd\u6570\u7528\u4e8e\u6253\u5f00\u6307\u5b9a\u8def\u5f84\u7684\u56fe\u7247\uff0c<code>plt.imshow<\/code>\u51fd\u6570\u7528\u4e8e\u663e\u793a\u56fe\u7247\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u6dfb\u52a0\u56fe\u7247\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec<strong>\u4f7f\u7528PIL\u5e93\u3001\u4f7f\u7528OpenCV\u5e93\u3001\u4f7f\u7528Matplotlib\u5e93<\/strong>\u3002\u5176\u4e2d\uff0c\u4f7f\u7528PIL\u5e93\u662f\u6700\u5e38\u89c1\u548c\u7b80\u4fbf\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u901a\u8fc7PIL\u5e93\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u6253\u5f00\u3001\u663e\u793a\u3001\u6dfb\u52a0\u6587\u5b57\u3001\u6dfb\u52a0\u56fe\u5f62\u3001\u56fe\u50cf\u5408\u6210\u3001\u8c03\u6574\u56fe\u7247\u5927\u5c0f\u3001\u65cb\u8f6c\u56fe\u7247\u3001\u88c1\u526a\u56fe\u7247\u7b49\u529f\u80fd\u3002\u800cOpenCV\u548cMatplotlib\u5e93\u4e5f\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u56fe\u50cf\u5904\u7406\u529f\u80fd\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5e93\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><p>\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u5e93\uff0c\u90fd\u9700\u8981\u6ce8\u610f\u56fe\u50cf\u5904\u7406\u4e2d\u7684\u4e00\u4e9b\u7ec6\u8282\u95ee\u9898\uff0c\u5982\u56fe\u50cf\u8def\u5f84\u3001\u56fe\u50cf\u683c\u5f0f\u3001\u5750\u6807\u7cfb\u7b49\u3002\u901a\u8fc7\u4e0d\u65ad\u7ec3\u4e60\u548c\u63a2\u7d22\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u638c\u63e1\u56fe\u50cf\u5904\u7406\u7684\u6280\u5de7\u548c\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728Python\u4e2d\u53ef\u4ee5\u4f7f\u7528\u54ea\u4e9b\u5e93\u6765\u6dfb\u52a0\u548c\u5904\u7406\u56fe\u7247\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u6709\u51e0\u4e2a\u6d41\u884c\u7684\u5e93\u53ef\u4ee5\u7528\u6765\u6dfb\u52a0\u548c\u5904\u7406\u56fe\u7247\u3002\u6700\u5e38\u7528\u7684\u5305\u62ecPIL\uff08Pillow\uff09\u3001OpenCV\u548cMatplotlib\u3002Pillow\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u9002\u7528\u4e8e\u6253\u5f00\u3001\u64cd\u4f5c\u548c\u4fdd\u5b58\u591a\u79cd\u683c\u5f0f\u7684\u56fe\u7247\u3002OpenCV\u5219\u66f4\u9002\u5408\u9700\u8981\u8fdb\u884c\u8ba1\u7b97\u673a\u89c6\u89c9\u5904\u7406\u7684\u5e94\u7528\uff0c\u800cMatplotlib\u5219\u4e3b\u8981\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\uff0c\u4f46\u4e5f\u53ef\u4ee5\u52a0\u8f7d\u548c\u5c55\u793a\u56fe\u7247\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5c06\u56fe\u7247\u5d4c\u5165\u5230GUI\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff1f<\/strong><br \/>\u5982\u679c\u4f60\u60f3\u5728\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6dfb\u52a0\u56fe\u7247\uff0c\u53ef\u4ee5\u4f7f\u7528Tkinter\u5e93\u3002\u901a\u8fc7Tkinter\u7684PhotoImage\u6216Label\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06\u56fe\u7247\u5d4c\u5165\u5230\u5e94\u7528\u7a0b\u5e8f\u754c\u9762\u4e2d\u3002\u9996\u5148\uff0c\u786e\u4fdd\u56fe\u7247\u7684\u8def\u5f84\u6b63\u786e\uff0c\u7136\u540e\u52a0\u8f7d\u56fe\u7247\u5e76\u5c06\u5176\u663e\u793a\u5728\u6240\u9700\u7684\u7ec4\u4ef6\u4e0a\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5904\u7406\u56fe\u7247\u7684\u5c3a\u5bf8\u548c\u683c\u5f0f\u8f6c\u6362\uff1f<\/strong><br \/>\u4f7f\u7528Pillow\u5e93\u53ef\u4ee5\u65b9\u4fbf\u5730\u8c03\u6574\u56fe\u7247\u7684\u5c3a\u5bf8\u548c\u8f6c\u6362\u683c\u5f0f\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528<code>resize()<\/code>\u65b9\u6cd5\u6765\u6539\u53d8\u56fe\u7247\u7684\u5927\u5c0f\uff0c\u5e76\u901a\u8fc7<code>save()<\/code>\u65b9\u6cd5\u5c06\u56fe\u7247\u4fdd\u5b58\u4e3a\u4e0d\u540c\u7684\u683c\u5f0f\uff08\u5982JPEG\u3001PNG\u7b49\uff09\u3002\u8fd9\u6837\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u4f18\u5316\u56fe\u7247\u7684\u52a0\u8f7d\u65f6\u95f4\u548c\u5b58\u50a8\u7a7a\u95f4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u6dfb\u52a0\u56fe\u7247\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5e38\u89c1\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528PIL\u5e93\u3001\u4f7f\u7528OpenCV\u5e93\u3001\u4f7f\u7528Matplotlib [&hellip;]","protected":false},"author":3,"featured_media":1165728,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1165722"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1165722"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1165722\/revisions"}],"predecessor-version":[{"id":1165729,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1165722\/revisions\/1165729"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1165728"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1165722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1165722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1165722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}