{"id":253987,"date":"2022-10-01T08:00:32","date_gmt":"2022-10-01T00:00:32","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=253987"},"modified":"2022-09-28T11:01:39","modified_gmt":"2022-09-28T03:01:39","slug":"python-clearness-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/python-clearness-linux.html","title":{"rendered":"Python\u5b9e\u73b0\u5236\u4f5c\u900f\u660e\u80cc\u666f\u7684\u7535\u5b50\u5370\u7ae0\u8be6\u89e3"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4e3a\u5927\u5bb6\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u5229\u7528Python\u8bed\u8a00\u5b9e\u73b0\u5236\u4f5c\u900f\u660e\u80cc\u666f\u7684\u7535\u5b50\u5370\u7ae0\uff0c\u6587\u4e2d\u7684\u793a\u4f8b\u4ee3\u7801\u8bb2\u89e3\u8be6\u7ec6\uff0c\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5\u5c1d\u8bd5\u4e00\u4e0b<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e00\u3001\u524d\u8a00<\/strong><\/div>\n

\u4eca\u5929\u5206\u4eab\u4e00\u4e2aPython \u5236\u4f5c\u900f\u660e\u80cc\u666f\u7684\u7535\u5b50\u5370\u7ae0\u7684\u4ee3\u7801\uff0c\u4ee3\u7801\u662f\u901a\u8fc7\u7f51\u7edc\u83b7\u5f97\u5e76\u6574\u7406\u7684\uff0c\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003\u548c\u5b66\u4e60\u3002<\/p>\n

\u4e8c\u3001\u6b65\u9aa4\u89e3\u6790<\/strong><\/div>\n

\u4ee3\u7801\u6211\u5df2\u8c03\u8bd5\u8fc7\u4e86\uff0c\u4e0b\u9762\u662f\u64cd\u4f5c\u6b65\u9aa4\uff1a<\/p>\n

    \n
  • \u5c06\u4ee3\u7801\u590d\u5236\u5230\u4f60\u7684py\u6587\u4ef6\u4e2d\uff0c\u4fdd\u5b58\u5728\u672c\u5730C\u76d8\u6839\u76ee\u5f55\u4e0b\uff0c\u540d\u4e3a\uff1aseal.py<\/li>\n
  • \u5728\u8fd0\u884c\u4ee3\u7801\u65f6\uff0c\u6839\u636e\u63d0\u793a\u5b89\u88c5\u76f8\u5e94\u6a21\u5757<\/li>\n
  • \u6839\u636e\u4f60\u7684\u5b9e\u9645\u60c5\u51b5\u4fee\u6539\u4ee3\u7801\u4e2d\u76f8\u5e94\u53c2\u6570<\/li>\n
  • Win+R\u8fd0\u884ccmd,\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\uff1apython C:\/seal.py\u56de\u8f66\u67e5\u770b\u7ed3\u679c<\/li>\n
  • \u53ef\u4ee5\u770b\u5230\u547d\u4ee4\u884c\u4e2d\u6253\u5370\u51fa\u76f8\u5e94\u4fe1\u606f\uff0c\u7b49\u5f85\u56fe\u7247\u751f\u6210\u5373\u53ef<\/li>\n<\/ul>\n

    \u81f3\u6b64\uff0c\u6211\u4eec\u5c31\u5b8c\u6210\u4e86Python \u5236\u4f5c\u900f\u660e\u80cc\u666f\u7684\u7535\u5b50\u5370\u7ae0\u7684\u7a0b\u5e8f\u6267\u884c\uff0c\u5927\u5bb6\u559c\u6b22\u7684\u8bb0\u5f97\u652f\u6301\u4e00\u4e0b\uff0c\u6709\u9047\u5230\u95ee\u9898\u7684\u968f\u65f6\u627e\u6211\u6c9f\u901a\u3002<\/p>\n

    \u4e09\u3001\u6e90\u4ee3\u7801\u548c\u8fd0\u884c\u6548\u679c<\/strong><\/div>\n
    1.\u6e90\u4ee3\u7801<\/strong><\/span><\/div>\n
    '''\r\nPython\u5236\u4f5c\u900f\u660e\u80cc\u666f\u7684\u7535\u5b50\u5370\u7ae0\r\n'''\r\n# \u5bfc\u5165\u5305\r\nfrom PIL import Image,ImageFont,ImageDraw, ImageFilter\r\nfrom math import pi, cos, sin, tan\r\nfrom random import randint\r\n  \r\n# \u5b9a\u4e49\u65b9\u6cd5\r\ndef is_Chinese(ch):\r\n    '''\u5224\u65ad\u5b57\u7b26\u662f\u5426\u4e3a\u4e2d\u6587'''\r\n    if '\\u4e00' <= ch <= '\\u9fff':\r\n        return True\r\n    return False\r\n  \r\n  \r\ndef pentagram(x, y, R, yDegree=0):\r\n    '''\r\n    \u8ba1\u7b97\u4e94\u89d2\u661f\u5404\u4e2a\u9876\u70b9\r\n    int R:\u4e94\u89d2\u661f\u7684\u957f\u8f74\r\n    int x, y:\u4e94\u89d2\u661f\u7684\u4e2d\u5fc3\u70b9\r\n    int yDegree:\u957f\u8f74\u4e0ey\u8f74\u7684\u5939\u89d2\r\n    '''\r\n    rad = pi \/ 180   # \u6bcf\u5ea6\u7684\u5f27\u5ea6\u503c\r\n    r = R * sin(18 * rad) \/ cos(36 * rad)   # \u4e94\u89d2\u661f\u77ed\u8f74\u7684\u957f\u5ea6\r\n  \r\n    # \u6c42\u53d6\u5916\u5708\u70b9\u5750\u6807\r\n    RVertex = [(x - (R * cos((90 + k * 72 + yDegree) * rad)), y - (R * sin((90 + k * 72 + yDegree) * rad))) for k in range(5)]\r\n    # \u6c42\u53d6\u5185\u5708\u70b9\u5750\u6807\r\n    rVertex = [(x - (r * cos((90 + 36 + k * 72 + yDegree) * rad)), y - (r * sin((90 + 36 + k * 72 + yDegree) * rad))) for k in range(5)]\r\n  \r\n    # \u9876\u70b9\u5de6\u8fb9\u4ea4\u53c9\u5408\u5e76\r\n    vertex = [x for y in zip(RVertex, rVertex) for x in y]\r\n    return vertex\r\n  \r\n  \r\ndef circle(x, y, r):\r\n    '''\u8ba1\u7b97\u5706\u7684\u4e0a\u4e0b\u5de6\u53f3\u5207\u70b9'''\r\n    return (x - r, y - r, x + r, y + r)\r\n  \r\n  \r\n# \u5b9a\u4e49\u7c7b\r\nclass Stamp:\r\n    def __init__(self,  edge = 5,               # \u56fe\u7247\u8fb9\u7f18\u7a7a\u767d\u7684\u8ddd\u79bb\r\n                        H = 160,                # \u5706\u5fc3\u5230\u4e2d\u5c42\u6587\u5b57\u4e0b\u8fb9\u7f18\u7684\u8ddd\u79bb\r\n                        R = 250,                # \u5706\u534a\u5f84\r\n                        border = 13,            # \u5b57\u5230\u5706\u5708\u5185\u4fa7\u7684\u8ddd\u79bb\r\n                        r = 90,                 # \u4e94\u661f\u5916\u63a5\u5706\u534a\u5f84\r\n                        fill = (255, 0, 0, 120),# \u5370\u7ae0\u989c\u8272\uff0c \u9ed8\u8ba4\u7eaf\u7ea2\u8272\uff0c \u900f\u660e\u5ea60-255\uff0c\u5efa\u8bae90-180\r\n  \r\n                        words_up = \"\", # \u4e0a\u90e8\u6587\u5b57\r\n                        angle_up = 270,         # \u4e0a\u90e8\u6587\u5b57\u5f27\u5f62\u89d2\u5ea6\r\n                        font_size_up = 80,      # \u4e0a\u90e8\u6587\u5b57\u5927\u5c0f\r\n                        font_xratio_up = 0.66,  # \u4e0a\u90e8\u6587\u5b57\u6a2a\u5411\u53d8\u5f62\u6bd4\u4f8b\r\n                        stroke_width_up = 2,    # \u4e0a\u90e8\u6587\u5b57\u7c97\u7ec6\uff0c\u4e00\u822c\u53d6\u503c0,1,2,3\r\n  \r\n                        words_mid=\"\",   # \u4e2d\u90e8\u6587\u5b57\r\n                        angle_mid = 72,         # \u4e2d\u90e8\u6587\u5b57\u5f27\u5f62\u89d2\u5ea6\r\n                        font_size_mid = 60,     # \u4e2d\u90e8\u6587\u5b57\u5927\u5c0f\r\n                        font_xratio_mid = 0.7,  # \u4e2d\u90e8\u6587\u5b57\u6a2a\u5411\u53d8\u5f62\u6bd4\u4f8b\r\n                        stroke_width_mid=1,     # \u4e2d\u90e8\u6587\u5b57\u7c97\u7ec6\uff0c\u4e00\u822c\u53d6\u503c0,1,2\r\n  \r\n                        words_down=\"\",# \u4e0b\u90e8\u6587\u5b57\r\n                        angle_down = 60,        # \u4e0b\u90e8\u6587\u5b57\u5f27\u5f62\u89d2\u5ea6\r\n                        font_size_down = 20,    # \u4e0b\u90e8\u6587\u5b57\u5927\u5c0f\r\n                        font_xratio_down = 1,   # \u4e0b\u90e8\u6587\u5b57\u6a2a\u5411\u53d8\u5f62\u6bd4\u4f8b\r\n                        stroke_width_down=1,    # \u4e0b\u90e8\u6587\u5b57\u7c97\u7ec6\uff0c\u4e00\u822c\u53d6\u503c0,1,2\r\n  \r\n                        img_wl_path = \"\", # \u7eb9\u7406\u56fe\u8def\u5f84\r\n                        save_path = \"\" # \u4fdd\u5b58\u56fe\u7247\u8def\u5f84\r\n                 ):\r\n  \r\n        # \u6253\u5f00\u7eb9\u7406\u56fe\u50cf\uff0c\u968f\u673a\u622a\u53d6\u65cb\u8f6c\r\n        self.img_wl = Image.open(img_wl_path)\r\n  \r\n        # \u56fe\u50cf\u521d\u59cb\u8bbe\u7f6e\u4e3aNone\r\n        self.img = None\r\n        self.save_path = save_path\r\n  \r\n        self.fill = fill                       # \u5370\u7ae0\u989c\u8272\r\n        self.edge = edge                       # \u56fe\u7247\u8fb9\u7f18\u7a7a\u767d\u7684\u8ddd\u79bb\r\n        self.H = H                             # \u5706\u5fc3\u5230\u4e2d\u5c42\u6587\u5b57\u4e0b\u8fb9\u7f18\u7684\u8ddd\u79bb\r\n        self.R = R                             # \u5706\u534a\u5f84\r\n        self.r = r                             # \u4e94\u661f\u5916\u63a5\u5706\u534a\u5f84\r\n        self.border = border                   # \u5b57\u5230\u5706\u5708\u5185\u4fa7\u7684\u8ddd\u79bb\r\n  \r\n        self.words_up = words_up               # \u4e0a\u90e8\u6587\u5b57\r\n        self.angle_up = angle_up               # \u4e0a\u90e8\u6587\u5b57\u5f27\u5f62\u89d2\u5ea6\r\n        self.font_size_up = font_size_up       # \u4e0a\u90e8\u6587\u5b57\u5927\u5c0f\r\n        self.font_xratio_up = font_xratio_up   # \u4e0a\u90e8\u6587\u5b57\u6a2a\u5411\u53d8\u5f62\u6bd4\u4f8b\r\n        self.stroke_width_up = stroke_width_up     # \u4e0a\u90e8\u6587\u5b57\u7c97\u7ec6\uff0c\u4e00\u822c\u53d6\u503c0,1,2,3\r\n  \r\n        self.words_mid = words_mid             # \u4e2d\u90e8\u6587\u5b57\r\n        self.angle_mid = angle_mid             # \u4e2d\u90e8\u6587\u5b57\u5f27\u5f62\u89d2\u5ea6\r\n        self.font_size_mid = font_size_mid     # \u4e2d\u90e8\u6587\u5b57\u5927\u5c0f\r\n        self.font_xratio_mid = font_xratio_mid # \u4e2d\u90e8\u6587\u5b57\u6a2a\u5411\u53d8\u5f62\u6bd4\u4f8b\r\n        self.stroke_width_mid = stroke_width_mid   # \u4e2d\u90e8\u6587\u5b57\u7c97\u7ec6\uff0c\u4e00\u822c\u53d6\u503c0,1,2,3\r\n  \r\n        self.words_down = words_down           # \u4e0b\u90e8\u6587\u5b57\r\n        self.angle_down = angle_down           # \u4e0b\u90e8\u6587\u5b57\u5f27\u5f62\u89d2\u5ea6\r\n        self.font_size_down = font_size_down   # \u4e0b\u90e8\u6587\u5b57\u5927\u5c0f\r\n        self.font_xratio_down = font_xratio_down  # \u4e0b\u90e8\u6587\u5b57\u6a2a\u5411\u53d8\u5f62\u6bd4\u4f8b\r\n        self.stroke_width_down = stroke_width_down   # \u4e2d\u90e8\u6587\u5b57\u7c97\u7ec6\uff0c\u4e00\u822c\u53d6\u503c0,1,2,3\r\n  \r\n  \r\n    def draw_rotated_text(self, image, angle, xy, r, word, fill, font_size, font_xratio, stroke_width, font_flip = False, *args, **kwargs):\r\n        \"\"\"\r\n        image:\u5e95\u5c42\u56fe\u7247\r\n        angle\uff1a\u65cb\u8f6c\u89d2\u5ea6\r\n        xy\uff1a\u65cb\u8f6c\u4e2d\u5fc3\r\n        r:\u65cb\u8f6c\u534a\u5f84\r\n        text\uff1a\u7ed8\u5236\u7684\u6587\u5b57\r\n        fill\uff1a\u6587\u5b57\u989c\u8272\r\n        font_size\uff1a\u5b57\u4f53\u5927\u5c0f\r\n        font_xratio\uff1ax\u65b9\u5411\u7f29\u653e\u6bd4\u4f8b\uff08\u5370\u7ae0\u5b57\u4f53\u5bbd\u5ea6\u8f83\u6807\u51c6\u5b8b\u4f53\u504f\u7a84\uff09\r\n        stroke_width\uff1a \u6587\u5b57\u7b14\u753b\u7c97\u7ec6\r\n        font_flip:\u6587\u5b57\u662f\u5426\u5782\u76f4\u7ffb\u8f6c\uff08\u5370\u7ae0\u4e0b\u90e8\u6587\u5b57\u4e0e\u4e0a\u90e8\u662f\u76f8\u53cd\u7684\uff09\r\n        \"\"\"\r\n  \r\n        # \u52a0\u8f7d\u5b57\u4f53\u6587\u4ef6-\u76f4\u63a5\u4f7f\u7528windows\u81ea\u5e26\u5b57\u4f53\uff0c\u4e2d\u6587\u7528simsun\uff0c \u82f1\u6587\u7528arial\r\n        if is_Chinese(word):\r\n            font = ImageFont.truetype(\"C:\/Windows\/Fonts\/simsun.ttc\", font_size, encoding=\"utf-8\")\r\n        else:\r\n            font = ImageFont.truetype(\"C:\/Windows\/Fonts\/arial.ttf\", font_size, encoding=\"utf-8\")\r\n  \r\n        # \u83b7\u53d6\u5e95\u5c42\u56fe\u7247\u7684size\r\n        width, height = image.size\r\n        max_dim = max(width, height)\r\n  \r\n        # \u521b\u5efa\u900f\u660e\u80cc\u666f\u7684\u6587\u5b57\u5c42\uff0c\u5927\u5c0f4\u500d\u7684\u5e95\u5c42\u56fe\u7247\r\n        mask_size = (max_dim * 2, max_dim * 2)\r\n        # \u5370\u7ae0\u901a\u5e38\u4f7f\u7528\u8f83\u7a84\u7684\u5b57\u4f53\uff0c\u8fd9\u91cc\u5c06\u7ed8\u5236\u6587\u5b57\u7684\u56fe\u5c42x\u65b9\u5411\u538b\u7f29\u5230font_xratio\u7684\u6bd4\u4f8b\r\n        mask_resize = (int(max_dim * 2 * font_xratio), max_dim * 2)\r\n        mask = Image.new('L', mask_size, 0)\r\n  \r\n        # \u5728\u4e0a\u9762\u6587\u5b57\u5c42\u7684\u4e2d\u5fc3\u5904\u5199\u5b57\uff0c\u5b57\u7684\u5de6\u4e0a\u89d2\u4e0e\u4e2d\u5fc3\u5bf9\u5176\r\n        draw = ImageDraw.Draw(mask)\r\n  \r\n        # \u83b7\u53d6\u5f53\u524d\u8bbe\u7f6e\u5b57\u4f53\u7684\u5bbd\u9ad8\r\n        bd = draw.textbbox((max_dim, max_dim), word, font=font, align=\"center\", *args, **kwargs)\r\n        font_width = bd[2] - bd[0]\r\n        font_hight = bd[3] - bd[1]\r\n  \r\n        # \u6587\u5b57\u5728\u5706\u5708\u4e0a\u4e0b\u7684\u65b9\u5411\uff0c\u9700\u8981\u901a\u8fc7\u6587\u5b57\u6240\u5728\u6587\u5b57\u56fe\u5c42\u7684\u4f4d\u7f6e\u4fee\u6b63\uff0c\u4fdd\u8bc1\u6240\u770b\u5230\u7684\u6587\u5b57\u4e0d\u4f1a\u4e0a\u4e0b\u98a0\u5012\r\n        if font_flip:\r\n            word_pos = (int(max_dim-font_width\/2), max_dim+r-font_hight)\r\n        else:\r\n            word_pos = (int(max_dim-font_width\/2), max_dim-r)\r\n  \r\n        # \u5199\u5b57\uff0c \u4ee5xy\u4e3a\u4e2d\u5fc3\uff0cr\u4e3a\u534a\u5f84\uff0c\u6587\u5b57\u4e0a\u8fb9\u4e2d\u70b9\u4e3a\u5706\u5468\u70b9\uff0c\u7ed8\u5236\u6587\u5b57\r\n        draw.text(word_pos, word, 255, font=font, align=\"center\",  stroke_width = stroke_width, *args, **kwargs)\r\n  \r\n        # \u8c03\u6574\u89d2\u5ea6,\u5bf9\u4e8e\u03a0*n\/2\u7684\u89d2\u5ea6\uff0c\u76f4\u63a5rotate\u5373\u53ef\uff0c\u5bf9\u4e8e\u975e\u03a0*n\/2\u7684\u89d2\u5ea6\uff0c\u9700\u8981\u5148\u653e\u5927\u56fe\u7247\u4ee5\u51cf\u5c11\u65cb\u8f6c\u5e26\u6765\u7684\u952f\u9f7f\r\n        if angle % 90 == 0:\r\n            rotated_mask = mask.resize(mask_resize).rotate(angle)\r\n        else:\r\n            bigger_mask = mask.resize((int(max_dim*8*font_xratio), max_dim*8),\r\n                                      resample=Image.BICUBIC)\r\n            rotated_mask = bigger_mask.rotate(angle).resize(mask_resize, resample=Image.LANCZOS)\r\n  \r\n        # \u5207\u5272\u6587\u5b57\u7684\u56fe\u7247\r\n        mask_xy = (max_dim*font_xratio - xy[0], max_dim - xy[1])\r\n        b_box = mask_xy + (mask_xy[0] + width, mask_xy[1] + height)\r\n        mask = rotated_mask.crop(b_box)\r\n  \r\n        # \u7c98\u8d34\u5230\u76ee\u6807\u56fe\u7247\u4e0a\r\n        color_image = Image.new('RGBA', image.size, fill)\r\n        image.paste(color_image, mask)\r\n  \r\n  \r\n    def draw_stamp(self):\r\n        #\u521b\u5efa\u4e00\u5f20\u5e95\u56fe,\u7528\u6765\u7ed8\u5236\u6587\u5b57\r\n        img = Image.new(\"RGBA\",(2*(self.R+self.edge),2*(self.R+self.edge)),(255,255,255,0))\r\n        draw = ImageDraw.Draw(img)\r\n  \r\n  \r\n        #\u7ed8\u5236\u5706\u5f27\uff0c R\u4e3a\u5916\u8fb9\u7f18\uff0cwidth\u5f80\u5706\u5fc3\u7b97\r\n        draw.arc(circle(self.R+self.edge, self.R+self.edge, self.R), start=0, end=360, fill=self.fill, width = self.border)\r\n  \r\n  \r\n        #\u7ed8\u5236\u591a\u8fb9\u5f62\r\n        draw.polygon(pentagram(self.R+self.edge,self.R+self.edge,self.r), fill=self.fill, outline=self.fill)\r\n  \r\n  \r\n        #\u7ed8\u5236\u4e0a\u5708\u6587\u5b57\r\n        angle_word = self.angle_up \/ len(self.words_up)\r\n        angle_word_curr = ((len(self.words_up)-1) \/ 2) * angle_word\r\n  \r\n        for word in self.words_up:\r\n            self.draw_rotated_text(img, angle_word_curr, (self.R+self.edge,self.R+self.edge), self.R-self.border*2, word, self.fill, self.font_size_up, self.font_xratio_up, self.stroke_width_up)\r\n            angle_word_curr = angle_word_curr - angle_word\r\n  \r\n  \r\n        #\u7ed8\u5236\u4e2d\u5c42\u6587\u5b57\r\n        angle_word = self.angle_mid \/ len(self.words_mid)\r\n        angle_word_curr = -((len(self.words_mid)-1) \/ 2) * angle_word\r\n  \r\n        for word in self.words_mid:\r\n            self.draw_rotated_text(img, 0, (self.R+self.edge+ self.H*tan(angle_word_curr*pi\/180),self.R+self.edge), self.H, word, self.fill, self.font_size_mid, self.font_xratio_mid, self.stroke_width_mid, font_flip = True)\r\n            angle_word_curr = angle_word_curr + angle_word\r\n  \r\n  \r\n        #\u7ed8\u5236\u4e0b\u5708\u6587\u5b57\r\n        angle_word = self.angle_down \/ len(self.words_down)\r\n        angle_word_curr = -((len(self.words_down)-1) \/ 2) * angle_word\r\n  \r\n        for word in self.words_down:\r\n            self.draw_rotated_text(img, angle_word_curr, (self.R+self.edge,self.R+self.edge), self.R-self.border*2, word, self.fill, self.font_size_down, self.font_xratio_down, self.stroke_width_down, font_flip = True)\r\n            angle_word_curr = angle_word_curr + angle_word\r\n  \r\n        # \u968f\u673a\u5708\u4e00\u90e8\u5206\u7eb9\u7406\u56fe\r\n        pos_random = (randint(0,200), randint(0,100))\r\n        box = (pos_random[0], pos_random[1], pos_random[0]+300, pos_random[1]+300)\r\n        img_wl_random = self.img_wl.crop(box).rotate(randint(0,360))\r\n        # \u91cd\u65b0\u8bbe\u7f6eim2\u7684\u5927\u5c0f\uff0c\u5e76\u8fdb\u884c\u4e00\u6b21\u9ad8\u65af\u6a21\u7cca\r\n        img_wl_random = img_wl_random.resize(img.size).convert('L').filter(ImageFilter.GaussianBlur(1))\r\n        # \u5c06\u7eb9\u7406\u56fe\u7684\u7070\u5ea6\u6620\u5c04\u5230\u539f\u56fe\u7684\u900f\u660e\u5ea6\uff0c\u7531\u4e8e\u7eb9\u7406\u56fe\u7247\u81ea\u5e26\u7070\u5ea6\uff0c\u6620\u5c04\u540e\u4f1a\u6709\u900f\u660e\u6548\u679c\uff0c\u6240\u4ee5fill\u7684\u900f\u660e\u5ea6\u4e0d\u80fd\u592a\u4f4e\r\n        L, H = img.size\r\n        for h in range(H):\r\n            for l in range(L):\r\n                dot = (l, h)\r\n                img.putpixel(dot, img.getpixel(dot)[:3]+(int(img_wl_random.getpixel(dot)\/255*img.getpixel(dot)[3]),))\r\n        # \u8fdb\u884c\u4e00\u6b21\u9ad8\u65af\u6a21\u7cca\uff0c\u63d0\u9ad8\u771f\u5b9e\u5ea6\r\n        self.img = img.filter(ImageFilter.GaussianBlur(0.6))\r\n  \r\n    def show_stamp(self):\r\n        if self.img:\r\n            self.img.show()\r\n  \r\n    def save_stamp(self):\r\n        if self.img:\r\n            self.img.save(self.save_path)\r\n  \r\n  \r\nif __name__ == '__main__':\r\n  \r\n    # \u4e0a\u9762\u7684\u5b57\r\n    words_up = \"\u5c0f\u5218\u5e26\u4f60\u5b66py\u6280\u672f\u793e\u533a\"\r\n    # \u4e2d\u95f4\u7684\u5b57\r\n    words_mid=\"\u793e\u533a\u4e13\u7528\u7ae0\"\r\n    # \u4e0b\u9762\u7684\u5b57\r\n    words_down=\"2022092415\"\r\n    # \u80cc\u666f\u56fe\u7247\u8def\u5f84\r\n    img_wl_path = \"D:\\Back1.jpg\"\r\n    # \u5370\u7ae0\u4fdd\u5b58\u8def\u5f84\r\n    save_path = \"D:\\A\\Project_1\\stamp.png\"\r\n  \r\n    # \u6267\u884c\u65b9\u6cd5\r\n    stamp = Stamp(words_up=words_up,words_mid=words_mid,words_down=words_down,img_wl_path=img_wl_path,save_path=save_path)\r\n    stamp.draw_stamp()\r\n    stamp.show_stamp()\r\n    stamp.save_stamp()<\/pre>\n
    2.\u8fd0\u884c\u6548\u679c\u56fe<\/strong><\/span><\/div>\n

    \"\"<\/p>\n

    \u5230\u6b64\u8fd9\u7bc7\u5173\u4e8ePython\u5b9e\u73b0\u5236\u4f5c\u900f\u660e\u80cc\u666f\u7684\u7535\u5b50\u5370\u7ae0\u7684\u6587\u7ae0\u5c31\u4ecb\u7ecd\u5230\u8fd9\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u4eca\u5929\u5206\u4eab\u4e00\u4e2aPython \u5236\u4f5c\u900f\u660e\u80cc\u666f\u7684\u7535\u5b50\u5370\u7ae0\u7684\u4ee3\u7801\uff0c\u4ee3\u7801\u662f\u901a\u8fc7\u7f51\u7edc\u83b7\u5f97\u5e76\u6574\u7406\u7684\uff0c\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003\u548c\u5b66\u4e60\u3002 \u4ee3\u7801 […]<\/p>\n","protected":false},"author":1482,"featured_media":222378,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-253987","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/253987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1482"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=253987"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/253987\/revisions"}],"predecessor-version":[{"id":254010,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/253987\/revisions\/254010"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/222378"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=253987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=253987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=253987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}