Comments (8)
I agree, this would be a useful feature. Hope anyone is willing to contribute on this.
from qr-code.
I'm guessing this ain't happening?
from qr-code.
Not unless someone is willing to contribute on this feature.
from qr-code.
Looks like the new core library used in 2.x supports this feature. Please try it and let me know if this works for you. Please note that documentation of 2.x is not yet up to date and some features like adding a logo or a label still need to be ported to this new version.
from qr-code.
Doesn't work for me, I'm trying
writeString(SvgWriter::class)
but I always get a png image. Tried playing around a bit (with MIME type etc) but to no avail: I get an encoding error when using image/svg+xml
Please help :(
from qr-code.
The SVG works perfectly. Here is how I used it:
$qrCode = new QrCode( get_site_url() . '/some/path/to/api/' );
$qrCode
->setMargin(10)
->setEncoding('UTF-8')
->setErrorCorrectionLevel( ErrorCorrectionLevel::HIGH )
->setBackgroundColor( [ 'r' => 255, 'g' => 255, 'b' => 255 ] )
->setForegroundColor( [ 'r' => 0, 'g' => 0, 'b' => 0 ] )
->setLabel( 'Test', 12, SD_PATH . 'vendor/endroid/qrcode/assets/noto_sans.otf', LabelAlignment::CENTER, [ 'b' => 20 ] )
->setLogoPath( SD_PATH . 'assets/img/eye.png')
->setLogoWidth( 150 )
->setSize(200)
->setWriterByName('png');
$svg = new SvgWriter();
echo $svg->writeString( $qrCode ) ;
It's important that you pass your original QrCode class instance back to SvgWriter, and in my case this was $qrCode instance above.
Of course there will be things like logos that won't work as you can't convert bitmap to vector, but for a quick SVG solution it works perfectly fine! I also do not see any code that allows for the label to be rendered using SVG.
The SVG also displays fine when just echo / printing it out, whereas the PNG needed to be base64_encoded as a data URI.
from qr-code.
@Emilio-Staropoli you should use the setWriter() method to set your writer or instantiate the SvgWrtier yourself and use its writeString method.
from qr-code.
1 more thing, set header header('Content-Type: '.$svg->getContentType());
to help browser understand it's SVG image
from qr-code.
Related Issues (20)
- Invalid image in README.md HOT 1
- Specifying QR code models HOT 2
- [Feature Request] PdfWriter sub-millimeter block size
- vcards HOT 1
- Problems using library HOT 1
- imagettfbbox(): Could not find/open font HOT 6
- Expected type 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelInterface'. Found 'Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh'. HOT 1
- PArameter documentation HOT 2
- Background color and margin for logo HOT 1
- How can I add an image with input type file? HOT 1
- Message: Interface "Endroid\QrCode\QrCodeInterface" not found HOT 1
- Modifying cells of the matrix HOT 3
- how to set the version of a qrcode HOT 1
- Question : how is it possible not displaying the label (for accessibility reasons) ? HOT 2
- Call to undefined method Endroid\QrCode\QrCode::create() HOT 3
- Image embedded in email contains full path to image HOT 2
- Could it be that the readme is outdated? HOT 2
- [Feature Request] SvgWriter with choice of code generation policy - Option to Use Previous SVG Generation Method with <defs> HOT 4
- Version 2+ really slow (xdebug) HOT 3
- Composer install problem 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 qr-code.