www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Just another QR code library

reply Andrea Fontana <nospam example.org> writes:
Hey everyone,

I've been working on a small project lately and thought I'd share 
it with you all. It's a simple QR code generation library. It is 
based on Project Nayuki's library.

The main idea behind it was to create something that doesn't rely 
on any external dependencies. I know how annoying it can be when 
you want to do something simple like generating a QR code, and 
you end up having to install a bunch of packages. So, this 
library is completely self-contained.

Some key points about it:

- No external dependencies, as mentioned.
- You can tweak various generation parameters to get the QR code 
just how you want it.
- It supports exporting to different formats: SVG, PNG, and PPM.

If you need something straightforward, this might be useful.

`dub add qr`

```d
import qr;
import std.stdio;

void main()
{
    // ASCII art FTW
    QrCode("Hello D!").writeln();

    // Save as PNG. Look, Ma, no external deps!
    QrCode("Hello D!").save("simple-qr.png");
}
```

The code and docs are up on GitHub https://github.com/trikko/qr

Feel free to check it out, use it if you find it helpful, and let 
me know if you run into any issues or have suggestions for 
improvements.
Cheers!

Andrea Fontana
Oct 16
next sibling parent Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Wednesday, 16 October 2024 at 12:58:29 UTC, Andrea Fontana 
wrote:
 Hey everyone,

 I've been working on a small project lately and thought I'd 
 share it with you all. It's a simple QR code generation 
 library. It is based on Project Nayuki's library.

 [...]
After watching the recent video of Veritasium, I was planning to write one. Yours seems great. It is al so a good example when you write things half in C and half in D with importC. https://www.youtube.com/watch?v=w5ebcowAJD8
Oct 17
prev sibling next sibling parent reply Salih Dincer <salihdb hotmail.com> writes:
On Wednesday, 16 October 2024 at 12:58:29 UTC, Andrea Fontana 
wrote:
 ```d
 import qr;
 import std.stdio;

 void main()
 {
    // ASCII art FTW
    QrCode("Hello D!").writeln();

    // Save as PNG. Look, Ma, no external deps!
    QrCode("Hello D!").save("simple-qr.png");
 }
 ```
 Feel free to check it out, use it if you find it helpful, and 
 let me know if you run into any issues or have suggestions for 
 improvements.
 Cheers!
I haven't tried it yet, but it's an excellent example of high-quality work, especially with the use of D's standard library and importC. Please accept my congratulations on your contribution. I have a small question: Is it possible to increase or decrease the image file resolution? SDB 79
Oct 17
parent reply Salih Dincer <salihdb hotmail.com> writes:
On Thursday, 17 October 2024 at 10:33:08 UTC, Salih Dincer wrote:
 I haven't tried it yet...
Now i noticed save(), this is one of the range functions; i think it's forwardrange. Hence the name which might cause confusion. SDB 79
Oct 17
parent reply Andrea Fontana <nospam example.org> writes:
On Thursday, 17 October 2024 at 10:40:33 UTC, Salih Dincer wrote:
 On Thursday, 17 October 2024 at 10:33:08 UTC, Salih Dincer 
 wrote:
 I haven't tried it yet...
Now i noticed save(), this is one of the range functions; i think it's forwardrange. Hence the name which might cause confusion. SDB 79
I was undecided whether to call the method 'save' or 'write', but 'write' usually has a different structure, and in this case, I'm actually saving a file.
Oct 17
parent reply Salih Dincer <salihdb hotmail.com> writes:
On Thursday, 17 October 2024 at 14:39:42 UTC, Andrea Fontana 
wrote:
 I was undecided whether to call the method 'save' or 'write', 
 but 'write' usually has a different structure, and in this 
 case, I'm actually saving a file.
My suggestion would be export, convert or better saveAs()... SDB 79
Oct 17
parent Andrea Fontana <nospam example.org> writes:
On Thursday, 17 October 2024 at 16:07:57 UTC, Salih Dincer wrote:
 On Thursday, 17 October 2024 at 14:39:42 UTC, Andrea Fontana 
 wrote:
 I was undecided whether to call the method 'save' or 'write', 
 but 'write' usually has a different structure, and in this 
 case, I'm actually saving a file.
My suggestion would be export, convert or better saveAs()... SDB 79
I'm considering saveAs for the next version, then! Andrea
Oct 17
prev sibling next sibling parent reply Christian =?UTF-8?B?S8O2c3RsaW4=?= <christian.koestlin gmail.com> writes:
On Wednesday, 16 October 2024 at 12:58:29 UTC, Andrea Fontana 
wrote:
 Hey everyone,
 ...
 - It supports exporting to different formats: SVG, PNG, and PPM.
 ...
 Andrea Fontana
Wow .. the png code is beautiful! Kind regards, Christian
Oct 17
parent Andrea Fontana <nospam example.com> writes:
On Thursday, 17 October 2024 at 17:40:30 UTC, Christian Köstlin 
wrote:
 On Wednesday, 16 October 2024 at 12:58:29 UTC, Andrea Fontana 
 wrote:
 Hey everyone,
 ...
 - It supports exporting to different formats: SVG, PNG, and 
 PPM.
 ...
 Andrea Fontana
Wow .. the png code is beautiful! Kind regards, Christian
Minimal! Andrea
Oct 17
prev sibling parent Andrea Fontana <nospam example.org> writes:
On Wednesday, 16 October 2024 at 12:58:29 UTC, Andrea Fontana 
wrote:
 Hey everyone,

 I've been working on a small project lately and thought I'd 
 share it with you all. It's a simple QR code generation 
 library. It is based on Project Nayuki's library.
I have released a small update with some improvements: - Added SVGZ format (still with no external dependencies!) - PNG files now use an indexed color palette and maximum compression - Deprecated save() in favor of saveAs() Now, a QRCode sized 2500x2500px (!) takes ~3.5KB as a PNG or ~750 bytes as an SVGZ. Andrea Fontana
Oct 18