Comments (5)
That's possible, but this project does not provide any helper function for this purpose since it requires more advanced image processing which is beyond the scope of this project.
However, Segno generates just simple PNG images which can be processed further.
Example code:
import io
from PIL import Image
import segno
out = io.BytesIO()
# Nothing special here, let Segno generate the QR code and save it as PNG in a buffer
segno.make('Blackbird singing in the dead of night', error='h').save(out, scale=5, kind='png')
out.seek(0) # Important to let Pillow load the PNG
img = Image.open(out)
# Ensure colors (Segno saves a grayscale PNG to reduce the file size), use 'RGBA' if you need transparency
img = img.convert('RGB')
img_width, img_height = img.size
logo_max_size = img_height // 3 # May use a fixed value as well
logo_img = Image.open('./blackbird.jpg') # The logo
# Resize the logo to logo_max_size
logo_img.thumbnail((logo_max_size, logo_max_size), Image.Resampling.LANCZOS)
# Calculate the center of the QR code
box = ((img_width - logo_img.size[0]) // 2, (img_height - logo_img.size[1]) // 2)
img.paste(logo_img, box)
img.save('qrcode_with_logo.png')
from segno.
See also https://github.com/heuer/segno/tree/master/examples/logo
from segno.
Thanks I will have a tinker ^_^
from segno.
How would I save the pasted image as a .svg? ie img.save("qrcode.svg")
Thanks
from segno.
How would I save the pasted image as a .svg? ie img.save("qrcode.svg")
That's unfortunately not possible.
Maybe utilizing the CairoSVG lib https://cairosvg.org/documentation/ would help? But I don't have an example at hand.
from segno.
Related Issues (20)
- Limitations on the maximum number of characters that can be entered HOT 4
- Segno GUI and Windows prebuilt executables HOT 2
- Creating QR Codes with Multiple Data Modes HOT 2
- url info not importing via QR vCard HOT 2
- Is it possible to round the edges HOT 2
- upable to load image in vcard qrcode
- Unable to create QR codes with modes less than binary/'bytes' HOT 2
- Malformed padding when number of bits is a multiple of 8 HOT 3
- reduce size of output HOT 1
- FYI - Deprecated warnings with: python -m build --wheel
- Fix for pillow 10
- pkg_resources is deprecated as an API.
- Unable to animate qr using .to_artistic() HOT 6
- Add image while using .make_mecard module HOT 4
- Remove plugin system HOT 2
- The default iso-8859-1 encoding unsafe, can be misdecoded by zbar as Big5 (was: Unicode-related test failures on musl libc) HOT 14
- Online demo using this library HOT 3
- Eyes and frames customize required! HOT 3
- Any plans to support currencies other than EUR? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from segno.