Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.0 #2

Merged
merged 8 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Python application

on:
push:
branches: [ "main" ]
branches: [ "main", "develop" ]
pull_request:
branches: [ "develop" ]
branches: [ "main", "develop" ]

permissions:
contents: read
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ jobs:
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# An rMQR Code Generator
![Lorem_ipsum](https://user-images.githubusercontent.com/14174940/171996095-4707be09-506e-4ef2-ab90-9942d6efc2ed.png)
![reop-url](https://user-images.githubusercontent.com/14174940/172978619-accbf9d0-9dd8-4b19-b47e-ad139a68dcc9.png)

This is an rMQR Code image generator implemented in Python.

This is an rMQR Code image generator implemented in Python. This is implemented based on [ISO/IEC 23941:2022](https://www.iso.org/standard/77404.html).

## Important Notice
Please verify an image generated by this software whether it can decode correctly before use.
Expand Down
2 changes: 1 addition & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main():
# print(qr)

# Save as png
image = QRImage(qr)
image = QRImage(qr, module_size=8)
image.show()
image.save("my_qr.png")

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = rmqrcode
version = 0.0.7
version = 0.1.0
author = Takahiro Tomita
author_email = [email protected]
description = An rMQR Code Generetor
Expand Down
16 changes: 13 additions & 3 deletions src/rmqrcode/qr_image.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from .enums.color import Color

from PIL import Image
from PIL import ImageDraw


class QRImage:
def __init__(self, qr):
self._img = Image.new('RGB', (qr.width() + 4, qr.height() + 4), (255, 255, 255))
def __init__(self, qr, module_size=10):
self._module_size = module_size
self._img = Image.new(
'RGB',
((qr.width() + 4) * module_size, (qr.height() + 4) * module_size),
(255, 255, 255)
)
self._make_image(qr)


Expand All @@ -19,11 +25,15 @@ def save(self, name):


def _make_image(self, qr):
draw = ImageDraw.Draw(self._img)
for y in range(qr.height()):
for x in range(qr.width()):
r, g, b = 125, 125, 125
if qr.value_at(x, y) == Color.BLACK:
r, g, b = 0, 0, 0
elif qr.value_at(x, y) == Color.WHITE:
r, g, b, = 255, 255, 255
self._img.putpixel((x+2, y+2), (r, g, b))
draw.rectangle(
xy=((x + 2) * self._module_size, (y + 2) * self._module_size, (x + 1 + 2) * self._module_size, (y + 1 + 2) * self._module_size),
fill=(r, g, b)
)