{"id":1717,"date":"2022-04-16T20:57:54","date_gmt":"2022-04-16T11:57:54","guid":{"rendered":"https:\/\/leenux.site\/?p=1717"},"modified":"2022-04-16T20:57:58","modified_gmt":"2022-04-16T11:57:58","slug":"python-qr%ec%bd%94%eb%93%9c-%eb%a7%8c%eb%93%a4%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/leenux.kr\/?p=1717","title":{"rendered":"[Python] QR\ucf54\ub4dc \ub9cc\ub4e4\uae30"},"content":{"rendered":"\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p class=\"has-black-color has-text-color has-medium-font-size\"><strong>\ud544\uc694 \ubaa8\ub4c8\ub4e4 \uc124\uce58\ud558\uae30<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">pip install qrcode\npip install PIL<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p class=\"has-black-color has-text-color has-medium-font-size\"><strong>\uadf8\ub0e5 QR\ucf54\ub4dc \ub9cc\ub4e4\uae30 <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">import qrcode\nfrom PIL import Image\n\n# <strong>QR\ucf54\ub4dc \ub9cc\ub4e4\uae30 <\/strong>\npath = \".\/\"\ndata = \"https:\/\/naver.com\" # \ub370\uc774\ud130 \uc9c0\uc815\nqr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_H)\nqr.add_data(data) # \ub370\uc774\ud130 \uc0bd\uc785\nqr.make() # \ub9cc\ub4e4\uae30\nqr_image = qr.make_image().convert('RGB') # RGB \uc774\ubbf8\uc9c0\ub85c QRCODE \ub9cc\ub4e4\uae30\n\nfile_name = \"test.png\" # \uc800\uc7a5 \ud30c\uc77c\uba85 \uc9c0\uc815\nqr_image.save(path + file_name) # QRCODE \uc774\ubbf8\uc9c0 \uc800\uc7a5<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p class=\"has-black-color has-text-color has-medium-font-size\"><strong>2. \uc9c0\uc815\ud55c \uc774\ubbf8\uc9c0 \uc911\uc559\uc5d0 \ub123\uc740 QR\ucf54\ub4dc \ub9cc\ub4e4\uae30<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"python\" class=\"language-python\">import qrcode\nfrom PIL import Image\n\n# <strong>\uc9c0\uc815\ud55c \uc774\ubbf8\uc9c0 \uc911\uc559\uc5d0 \ub123\uc740 QR\ucf54\ub4dc \ub9cc\ub4e4\uae30<\/strong>\npath = \".\/\"\nadd_image_path = \"\"\n\nadd_image = Image.open(add_image_path)#.crop((150, 40, 235, 150)) # \ubd99\ud788 \uc774\ubbf8\uc9c0 \uac00\uc838\uc624\uae30\nadd_image.thumbnail((60, 60))\nqr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_H) # QRCODE \uc5d0\ub7ec \uc9c0\uc815\ndata = \"https:\/\/naver.com\" # \ub370\uc774\ud130 \uc9c0\uc815\nqr.add_data(data) # \ub370\uc774\ud130 \uc0bd\uc785\nqr.make() # \ub9cc\ub4e4\uae30\n\nresult = qr.make_image().convert('RGB') # \uc774\ubbf8\uc9c0 \ub9cc\ub4e4\uae30 (RGB\ub85c \uc800\uc7a5)\n\n# \ubc14\ucf54\ub4dc \uc774\ubbf8\uc9c0 X, Y \uac01\uac01 \uc88c\ud3b8\uc758 \ubc18\uc808\uac12 \uad6c\ud558\uace0 \ubd99\ud790 \uc774\ubbf8\uc9c0 X, Y \uac01\uac01 \uc88c\ud3b8\uc758 \ubc18\uc808\uac12\uad6c\ud558\uace0 \ubeb4\uae30\npos = ((result.size[0] \/\/ 2) - (add_image.size[0] \/\/ 2), (result.size[1] \/\/ 2) - (add_image.size[1] \/\/ 2))\n\n\nresult.paste(add_image, pos) # \ubc14\ucf54\ub4dc \uc774\ubbf8\uc9c0\uc5d0 \ubd99\ud790 \uc774\ubbf8\uc9c0\uc640 \uc704\uce58\nfile_name = \"test.png\" # \ud30c\uc77c \uc774\ub984 \uc9c0\uc815\nresult.save(path + file_name) # \ud30c\uc77c \uc800\uc7a5\nprint(result.size)<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Python] QR\ucf54\ub4dc \ub9cc\ub4e4\uae30<\/p>\n","protected":false},"author":1,"featured_media":732,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/leenux.kr\/index.php?rest_route=\/wp\/v2\/posts\/1717"}],"collection":[{"href":"https:\/\/leenux.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leenux.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leenux.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/leenux.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1717"}],"version-history":[{"count":1,"href":"https:\/\/leenux.kr\/index.php?rest_route=\/wp\/v2\/posts\/1717\/revisions"}],"predecessor-version":[{"id":1718,"href":"https:\/\/leenux.kr\/index.php?rest_route=\/wp\/v2\/posts\/1717\/revisions\/1718"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/leenux.kr\/index.php?rest_route=\/wp\/v2\/media\/732"}],"wp:attachment":[{"href":"https:\/\/leenux.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leenux.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leenux.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}