Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyVcardToQr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tetras-libre
PyVcardToQr
Commits
fdd3968f
Verified
Commit
fdd3968f
authored
2 years ago
by
David Beniamine
Browse files
Options
Downloads
Patches
Plain Diff
Reduce image size to avoid error on small data
parent
1e2c58d2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyVcardToQr/pyVcardToQr.py
+8
-10
8 additions, 10 deletions
pyVcardToQr/pyVcardToQr.py
with
8 additions
and
10 deletions
pyVcardToQr/pyVcardToQr.py
+
8
−
10
View file @
fdd3968f
...
@@ -22,16 +22,6 @@ def getCard(first, last, data):
...
@@ -22,16 +22,6 @@ def getCard(first, last, data):
def
genQr
(
data
,
output
,
colors
=
(
'
black
'
,
'
white
'
),
logo_path
=
None
):
def
genQr
(
data
,
output
,
colors
=
(
'
black
'
,
'
white
'
),
logo_path
=
None
):
if
logo_path
is
not
None
:
logo
=
Image
.
open
(
logo_path
)
# taking base width
basewidth
=
100
# adjust image size
wpercent
=
(
basewidth
/
float
(
logo
.
size
[
0
]))
hsize
=
int
((
float
(
logo
.
size
[
1
])
*
float
(
wpercent
)))
logo
=
logo
.
resize
((
basewidth
,
hsize
),
Image
.
ANTIALIAS
)
QRcode
=
qrcode
.
QRCode
()
QRcode
=
qrcode
.
QRCode
()
# adding URL or text to QRcode
# adding URL or text to QRcode
...
@@ -45,6 +35,14 @@ def genQr(data, output, colors=('black', 'white'), logo_path=None):
...
@@ -45,6 +35,14 @@ def genQr(data, output, colors=('black', 'white'), logo_path=None):
img
=
QRcode
.
make_image
(
fill_color
=
fill
,
back_color
=
back
).
convert
(
'
RGB
'
)
img
=
QRcode
.
make_image
(
fill_color
=
fill
,
back_color
=
back
).
convert
(
'
RGB
'
)
if
logo_path
is
not
None
:
if
logo_path
is
not
None
:
logo
=
Image
.
open
(
logo_path
)
# taking base width
basewidth
=
min
(
int
(
10
*
img
.
width
/
100
),
100
)
# adjust image size
wpercent
=
(
basewidth
/
float
(
logo
.
size
[
0
]))
hsize
=
int
((
float
(
logo
.
size
[
1
])
*
float
(
wpercent
)))
logo
=
logo
.
resize
((
basewidth
,
hsize
),
Image
.
ANTIALIAS
)
# set size of QR code
# set size of QR code
pos
=
((
img
.
size
[
0
]
-
logo
.
size
[
0
])
//
2
,
pos
=
((
img
.
size
[
0
]
-
logo
.
size
[
0
])
//
2
,
(
img
.
size
[
1
]
-
logo
.
size
[
1
])
//
2
)
(
img
.
size
[
1
]
-
logo
.
size
[
1
])
//
2
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment