{"id":3654,"date":"2021-10-20T22:47:55","date_gmt":"2021-10-20T13:47:55","guid":{"rendered":"https:\/\/www.python.ambitious-engineer.com\/?p=3654"},"modified":"2021-10-20T22:47:55","modified_gmt":"2021-10-20T13:47:55","slug":"qr%e3%82%b3%e3%83%bc%e3%83%89%e3%81%ae%e7%94%9f%e6%88%90%e3%81%a8%e4%bf%9d%e5%ad%98","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/3654","title":{"rendered":"QR\u30b3\u30fc\u30c9\u306e\u751f\u6210\u3068\u4fdd\u5b58"},"content":{"rendered":"<p>\u3053\u306e\u30da\u30fc\u30b8\u3067\u306fPython\u306e\u30e9\u30a4\u30d6\u30e9\u30eaqrcode\u3092\u4f7f\u7528\u3057\u3066QR\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h2>qrcode<\/h2>\n<p>\u305d\u306e\u307e\u307e\u305a\u3070\u308aqrcode\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3059\u308b\u3068qr\u30b3\u30fc\u30c9\u306e\u751f\u6210\u304c\u53ef\u80fd\u3067\u3059\u3002GitHub\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u304c\u308f\u304b\u308a\u3084\u3059\u3044\u305f\u3081\u4e00\u8aad\u3059\u308b\u3053\u3068\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/pypi.org\/project\/qrcode\/\">qrcode PyPI<\/a><br \/>\n<a href=\"https:\/\/github.com\/lincolnloop\/python-qrcode\">https:\/\/github.com\/lincolnloop\/python-qrcode<\/a><\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002Pillow\u304c\u540c\u68b1\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\npip install qrcode[pil]\r\n<\/pre>\n<h2>QR\u30b3\u30fc\u30c9\u306e\u751f\u6210\u3068\u4fdd\u5b58<\/h2>\n<h3>\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h3>\n<p>qrcode\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3001qrcode.QRCode\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3001add_data\u3067\u30c7\u30fc\u30bf\u8a2d\u5b9a\u3001make_image\u3067QR\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002make_image\u306e\u623b\u308a\u5024\u306fPillow\u306eImage\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u306a\u306e\u3067\u3001show\u3067\u78ba\u8a8d\u306e\u305f\u3081\u306b\u8868\u793a\u3057\u305f\u308asave\u3067\u4fdd\u5b58\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<div class=\"related_article cf\"><a href=\"https:\/\/www.python.ambitious-engineer.com\/archives\/1815\" class=\"cf\"><figure class=\"eyecatch thum\"><img width=\"300\" height=\"200\" src=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2018\/08\/eyecatch_pillow-300x200.png\" class=\"attachment-home-thum size-home-thum wp-post-image\" alt=\"\" loading=\"lazy\" \/><\/figure><div class=\"meta inbox\"><p class=\"ttl\">Pillow\u306e\u4f7f\u3044\u65b9<\/p><span class=\"date\">2018\u5e748\u670812\u65e5<\/span><\/div><\/a><\/div>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u306fPython\u516c\u5f0f\u30b5\u30a4\u30c8\u306eURL\u3092QR\u30b3\u30fc\u30c9\u306b\u5909\u63db\u3057\u8868\u793a\u3057\u305f\u5f8c\u4fdd\u5b58\u3057\u3066\u3044\u307e\u3059\u3002\u306a\u304a\u3001make_image\u306e\u5f15\u6570\u3067\u30dc\u30c3\u30af\u30b9\u306e\u8272\u3068\u80cc\u666f\u8272\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport qrcode\r\n\r\nqr = qrcode.QRCode()\r\nqr.add_data('https:\/\/www.python.org\/')\r\nimg = qr.make_image(fill_color=&quot;black&quot;, back_color=&quot;white&quot;)\r\nimg.show()\r\nimg.save(&quot;sample1.png&quot;)\r\n<\/pre>\n<a href=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qr_sample1.png\"><img loading=\"lazy\" src=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qr_sample1.png\" alt=\"\" width=\"330\" height=\"330\" class=\"alignnone size-full wp-image-3661\" srcset=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qr_sample1.png 330w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qr_sample1-300x300.png 300w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qr_sample1-150x150.png 150w\" sizes=\"(max-width: 330px) 100vw, 330px\" \/><\/a>\n<h3>QR\u30b3\u30fc\u30c9\u306e\u8a2d\u5b9a<\/h3>\n<p>\u7d30\u304b\u3044\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3092\u3057\u305f\u3044\u5834\u5408\u306fqrcode.QRCode\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3059\u308b\u969b\u306b\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u30b5\u30a4\u30ba\u3084\u30d0\u30fc\u30b8\u30e7\u30f3\u3001\u8aa4\u308a\u8a02\u6b63\u30ec\u30d9\u30eb\u7b49\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>box_size\uff1a\u30d1\u30e9\u30e1\u30fc\u30bf\u306fQR\u30b3\u30fc\u30c9\u306e\u5404\u30dc\u30c3\u30af\u30b9\u306e\u30d4\u30af\u30bb\u30eb\u6570\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<li>border\uff1a\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306f\u5883\u754c\u7dda\u306e\u592a\u3055\u306e\u30dc\u30c3\u30af\u30b9\u306e\u6570\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\u306f\u6700\u5c0f\u5024\u306e4\u3068\u306a\u308a\u307e\u3059\uff09\u3002<\/li>\n<li>version\uff1a\u3067QR\u30b3\u30fc\u30c9\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u30c7\u30fc\u30bf\u91cf\u3068\u306a\u3089\u3073QR\u30b3\u30fc\u30c9\u306e\u5927\u304d\u306a\u30e1\u30ea\u30c3\u30c8\u3068\u3057\u3066\u8aa4\u308a\u8a02\u6b63\u304c\u3067\u304d\u308b\u3001\u3068\u3044\u3046\u70b9\u304c\u6319\u3052\u3089\u308c\u307e\u3059\u3002qrcode\u306f\u4ee5\u4e0b\u306e\u8aa4\u308a\u8a02\u6b63\u30ec\u30d9\u30eb\u304c\u6307\u5b9a\u3067\u304d\u307e\u3059\u304c\u300150%\u306e\u30ec\u30d9\u30ebS\u306f\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u306a\u304a\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306fERROR_CORRECT_M\u00a0\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>RROR_CORRECT_L\uff1a\u7d047\uff05\u4ee5\u4e0b\u306e\u8aa4\u308a\u3092\u8a02\u6b63<\/li>\n<li>ERROR_CORRECT_M\uff1a\u7d0415\uff05\u4ee5\u4e0b\u306e\u8aa4\u308a\u3092\u8a02\u6b63<\/li>\n<li>ERROR_CORRECT_Q\uff1a\u7d0415\uff05\u4ee5\u4e0b\u306e\u8aa4\u308a\u3092\u8a02\u6b63<\/li>\n<li>ERROR_CORRECT_H\uff1a\u7d0415\uff05\u4ee5\u4e0b\u306e\u8aa4\u308a\u3092\u8a02\u6b63<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u30d0\u30fc\u30b8\u30e7\u30f37\u3001\u8aa4\u308a\u8a02\u6b6330%\u3001\u30dc\u30c3\u30af\u30b9\u30b5\u30a4\u30ba5\u3001\u30dc\u30fc\u30c0\u30fc7\u3067QR\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport qrcode\r\n\r\nqr = qrcode.QRCode(\r\n    version=7,\r\n    error_correction=qrcode.constants.ERROR_CORRECT_L,\r\n    box_size=5,\r\n    border=7,\r\n)\r\nqr.add_data('https:\/\/www.python.org\/')\r\nimg = qr.make_image(fill_color=&quot;black&quot;, back_color=&quot;white&quot;)\r\nimg.show()\r\nimg.save(&quot;sample-qr.png&quot;)\r\n<\/pre>\n<a href=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qr-sample2.png\"><img loading=\"lazy\" src=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qr-sample2.png\" alt=\"\" width=\"295\" height=\"295\" class=\"alignnone size-full wp-image-3662\" srcset=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qr-sample2.png 295w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qr-sample2-150x150.png 150w\" sizes=\"(max-width: 295px) 100vw, 295px\" \/><\/a>\n<h2>\u30b9\u30bf\u30a4\u30eb\u306e\u8a2d\u5b9a<\/h2>\n<p>qrcode\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u306fQR\u30b3\u30fc\u30c9\u306e\u30dc\u30c3\u30af\u30b9\u306e\u30b9\u30bf\u30a4\u30eb\u3092\u6307\u5b9a\u3059\u308b\u3082\u306e\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u30ad\u30e3\u30f3\u30da\u30fc\u30f3\u7b49\u3067\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u30a4\u30e1\u30fc\u30b8\u306b\u5408\u308f\u305b\u305f\u30b9\u30bf\u30a4\u30eb\u3092\u9078\u3076\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u306d\u3002\u305f\u3060\u3057\u3001\u3053\u3046\u3044\u3063\u305f\u30b9\u30bf\u30a4\u30eb\u3092\u9069\u7528\u3057\u305fQR\u30b3\u30fc\u30c9\u306f\u30b9\u30ad\u30e3\u30ca\u306b\u3088\u3063\u3066\u306f\u52d5\u4f5c\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u3044\u3046\u70b9\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002qrcode.image.styles.moduledrawers\u914d\u4e0b\u306e\u30b9\u30bf\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u69d8\u3005\u306a\u30b9\u30bf\u30a4\u30eb\u306eQR\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport qrcode\r\nfrom qrcode.image.styledpil import StyledPilImage\r\nfrom qrcode.image.styles.moduledrawers import GappedSquareModuleDrawer, CircleModuleDrawer, RoundedModuleDrawer, \\\r\n    VerticalBarsDrawer, HorizontalBarsDrawer\r\n\r\nqr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_L)\r\nqr.add_data('https:\/\/www.python.org\/')\r\n\r\nimg_1 = qr.make_image(image_factory=StyledPilImage, module_drawer=GappedSquareModuleDrawer())\r\nimg_2 = qr.make_image(image_factory=StyledPilImage, module_drawer=CircleModuleDrawer())\r\nimg_3 = qr.make_image(image_factory=StyledPilImage, module_drawer=RoundedModuleDrawer())\r\nimg_4 = qr.make_image(image_factory=StyledPilImage, module_drawer=VerticalBarsDrawer())\r\nimg_5 = qr.make_image(image_factory=StyledPilImage, module_drawer=HorizontalBarsDrawer())\r\n\r\nimg_1.save(&quot;GappedSquareModuleDrawer.png&quot;)\r\nimg_2.save(&quot;CircleModuleDrawer.png&quot;)\r\nimg_3.save(&quot;RoundedModuleDrawer.png&quot;)\r\nimg_4.save(&quot;VerticalBarsDrawer.png&quot;)\r\nimg_5.save(&quot;HorizontalBarsDrawer.png&quot;)\r\n<\/pre>\n<a href=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_styles.png\"><img loading=\"lazy\" src=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_styles-1024x228.png\" alt=\"\" width=\"654\" height=\"146\" class=\"alignnone size-large wp-image-3655\" srcset=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_styles-1024x228.png 1024w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_styles-300x67.png 300w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_styles-768x171.png 768w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_styles-1536x342.png 1536w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_styles-718x160.png 718w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_styles.png 1557w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/a>\n<h2>\u753b\u50cf\u306e\u57cb\u3081\u8fbc\u307f<\/h2>\n<p>\u753b\u50cf\u3092\u57cb\u3081\u8fbc\u3080\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002Pillow\u3067\u5ea7\u6a19\u8a08\u7b97\u3092\u3057\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001embeded_image_path\u3092\u6307\u5b9a\u3059\u308b\u3068\u753b\u50cf\u3092\u771f\u3093\u4e2d\u306b\u57cb\u3081\u8fbc\u3080\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u3053\u308c\u306f\u8aa4\u308a\u8a02\u6b63\u6a5f\u80fd\u3092\u6d3b\u7528\u3057\u3066\u3044\u308b\u308f\u3051\u3067\u3059\u304c\u3001\u78ba\u5b9f\u306b\u52d5\u4f5c\u3059\u308b\u3068\u306f\u9650\u3089\u306a\u3044\u305f\u3081\u516c\u5f0f\u306e\u898b\u89e3\u3067\u306f\u975e\u63a8\u5968\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<a href=\"https:\/\/www.qrcode.com\/faq.html\">\u53c2\u8003:FAQ\uff5cQR\u30b3\u30fc\u30c9\u30c9\u30c3\u30c8\u30b3\u30e0<\/a><\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport qrcode\r\nfrom qrcode.image.styledpil import StyledPilImage\r\n\r\nqr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_L)\r\nqr.add_data('https:\/\/www.python.org\/')\r\nimg = qr.make_image(image_factory=StyledPilImage, embeded_image_path=&quot;python-powered-h-50x65.png&quot;)\r\nimg.save(&quot;embed.png&quot;)\r\n\r\n<\/pre>\n<a href=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_embed.png\"><img loading=\"lazy\" src=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_embed.png\" alt=\"\" width=\"330\" height=\"330\" class=\"alignnone size-full wp-image-3656\" srcset=\"https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_embed.png 330w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_embed-300x300.png 300w, https:\/\/www.python.ambitious-engineer.com\/wp-content\/uploads\/2021\/10\/qrcode_embed-150x150.png 150w\" sizes=\"(max-width: 330px) 100vw, 330px\" \/><\/a>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u30da\u30fc\u30b8\u3067\u306fPython\u306e\u30e9\u30a4\u30d6\u30e9\u30eaqrcode\u3092\u4f7f\u7528\u3057\u3066QR\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002 qrcode \u305d\u306e\u307e\u307e\u305a\u3070\u308aqrcode\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u7528\u3059\u308b\u3068qr\u30b3\u30fc\u30c9\u306e\u751f\u6210\u304c\u53ef\u80fd\u3067\u3059\u3002GitHub\u306e\u30c9\u30ad...<\/p>\n","protected":false},"author":1,"featured_media":3658,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/3654"}],"collection":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/comments?post=3654"}],"version-history":[{"count":5,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/3654\/revisions"}],"predecessor-version":[{"id":3665,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/3654\/revisions\/3665"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/3658"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=3654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=3654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=3654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}