-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from HackRU/transparent_qr_background
Transparent qr background
- Loading branch information
Showing
3 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
# run with `chromium $(python qr_script.py test@example.com)` | ||
|
||
import io | ||
import qrcode | ||
import PIL | ||
import base64 | ||
import sys | ||
|
||
def email2qr(email): | ||
#construct the QR code | ||
img = qrcode.make(email) | ||
#save as a byte array | ||
byteArr = io.BytesIO() | ||
img.save(byteArr, format='PNG') | ||
byteImg = byteArr.getvalue() | ||
#then read and encode. | ||
encodedImg = base64.standard_b64encode(byteImg) | ||
return 'data:image/png;base64,' + encodedImg.decode() | ||
|
||
if __name__ == '__main__': | ||
email = sys.argv[1] if len(sys.argv) >= 2 else 'test@example.com' | ||
print(email2qr(email)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
# run with `chromium $(./qr_script.sh test@example.com)` | ||
email='test@example.com' | ||
if test $# -ge 1 | ||
then | ||
email=$1 | ||
fi | ||
curl -H "content-type: application/json" -d "{\"email\": \"$email\", \"color\": [0,0,0], \"background\": [255,255,255]}" https://m7cwj1fy7c.execute-api.us-west-2.amazonaws.com/test/qr | grep -o 'data.*",' | sed 's/..$//' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters