-
-
Notifications
You must be signed in to change notification settings - Fork 320
Change QR Code colors #89
-
In many QR code generators they allow you to change colors for the different elements of the QR Code.
Is this possible here or it could be a future ... feature 😄
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 3 comments 6 replies
-
Uh that's literally a feature?
Beta Was this translation helpful? Give feedback.
All reactions
-
Well, I can't seem to find an example of that. Things like specific colors for specific squares, etc. Could you point me in the right direction?
Beta Was this translation helpful? Give feedback.
All reactions
-
It's all in the /examples directory. https://github.com/chillerlan/php-qrcode/blob/main/examples/image.php
In case you want to color individual pixels, i.e. for a pixel art logo, you will need to extend the respective output module similar to this example: https://github.com/chillerlan/php-qrcode/blob/main/examples/QRImageWithLogo.php
Beta Was this translation helpful? Give feedback.
All reactions
-
Hello,
Could you provide the options to generate a QRCode like the beautiful rainbow one that you present on the homepage ?
I tried many things using the examples but mines are horrible... i can't reproduce a nice QRCode. Especially to have circular spaced dot ...
Thanks for helping
Beta Was this translation helpful? Give feedback.
All reactions
-
Hey, it's in the SVG example of the current main branch, install it with the following composer.json to fetch the correct version:
{
"require": {
"php": "^7.4",
"chillerlan/php-qrcode": "dev-main#06730361508c283a02bbf9cbc9e4b55e7b3bc88b"
}
}Beta Was this translation helpful? Give feedback.
All reactions
-
Hey, thanks for reply so fast.
I confirm that the code is working with the main branch but in my project I took the version ^4.3 with composer as I am working with php 7.4.. And in that branch of course the variables are not the same "EccLevel::L and QRMatrix::IS_DARK" are undefined :)
I thought that I should not be using the "dev-main" branch for prod environment ? What do you recommend ?
Last question, I would like to render the QR code in a php function that does other things (like retrieve an article for the DB). Because I wanted to add the generated qr_code SVG as a variable and then display it in the view. But this is not working.
I mean the render only works when I call a specific route for the generator with the headers. But I want to generate it in my controller and not in the view.
Beta Was this translation helpful? Give feedback.
All reactions
-
Hey, thanks for reply so fast.
I confirm that the code is working with the main branch but in my project I took the version ^4.3 with composer as I am working with php 7.4.. And in that branch of course the variables are not the same "EccLevel::L and QRMatrix::IS_DARK" are undefined :)
I thought that I should not be using the "dev-main" branch for prod environment ? What do you recommend ?
The QR Code generator is almost done, the pending changes will mostly affect the reader/decoder which was not part of the library previously. So at this point it's quite safe to use dev-main and later upgrade to v5 once it's released without breaking anything (granted that it's in your own project and you can easily upgrade).
Last question, I would like to render the QR code in a php function that does other things (like retrieve an article for the DB). Because I wanted to add the generated qr_code SVG as a variable and then display it in the view. But this is not working. I mean the render only works when I call a specific route for the generator with the headers. But I want to generate it in my controller and not in the view.
What exactly is the question here? Where to put the QR output? Like, retrieve the data from the controller/model and render in the view? Or render in the controller and hand over the data blob to the view?
Beta Was this translation helpful? Give feedback.
All reactions
-
The QR Code generator is almost done, the pending changes will mostly affect the reader/decoder which was not part of the library previously. So at this point it's quite safe to use dev-main and later upgrade to v5 once it's released without breaking anything (granted that it's in your own project and you can easily upgrade).
Great news ! I'll stay on the dev-main and then switch to v5 as suggested !
What exactly is the question here? Where to put the QR output? Like, retrieve the data from the controller/model and render in the view? Or render in the controller and hand over the data blob to the view?
Sorry for confusion, hard to be clear as I'm not a native english. But forget about that, the QR code was not displayed on the view because of CSS issues. It's well displayed somewhere else on the page :)
Big thank for your time, and your work on this amazing project, but I don't thank you for having been Rick Rolled ^_^
Beta Was this translation helpful? Give feedback.
All reactions
-
Big thank for your time, and your work on this amazing project, but I don't thank you for having been Rick Rolled ^_^
Happy to help! Also, one shall appreciate the rickroll as it is one of the most wholesome memes on the internet and as it turns out, Rick Astley is a gem of a human :)
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1