giandonatoinverso / PHP-Dynamic-Qr-code

PHP Dynamic Qr code is a script that allows the generation and saving of dynamic and static QR codes
MIT License
243 stars 73 forks source link

self hosted qr-code generator insted of api.qrserver.com possible ? #88

Open n00bsi opened 4 months ago

n00bsi commented 4 months ago

Hello, is it possible to have a self-hosted qr-generator insted of api.qrserver.com ? So that no external service is need. So that no external dependencies are needed.

is it possible to use the tool: qrencode

giandonatoinverso commented 4 months ago

Hi, your proposal is very interesting. I invite you to contribute to the project

tranmh commented 4 months ago

Hi,

I have the same idea and start to fork another project called go-qrcode: https://github.com/tranmh/go-qrcode/blob/master/qrcode-restapi/main.go

go-qrcode has now a restapi and your code at line: https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code/blob/master/src/lib/Qrcode/Qrcode.php#L83

can call it using: $url = 'http://localhost:6868/api/qrcode?data=https%3A%2F%2Fsvw.info&size=256';

What is your expectation? I assume we need go-qrcode with restapi as git submodule. What else do you need to accept a pull request?

Thx.

giandonatoinverso commented 4 months ago

Hi, the creation method you propose doesn't have the same customization possibilities (or better) that are currently in use, so it's not good

tranmh commented 4 months ago

Sure, wait for the other Pull Request: https://github.com/skip2/go-qrcode/pull/66

If this PR is going into their repo, I will extend the customization possibilities. Which of those is a must-have for you?

giandonatoinverso commented 4 months ago

I want the actual customization of my script. Thanks

tranmh commented 4 months ago

In PR https://github.com/skip2/go-qrcode/pull/66 I added another improvement: "add support for ecc aka recovery level, color and background-color". and would look like this: http://localhost:6868/api/qrcode?data=abc&size=800&color=00FF00&bgcolor=FF00FF&ecc=L

giandonatoinverso commented 4 months ago

Is it already working?

tranmh commented 4 months ago

yes. PR is not accept yet, but I tested on my local machined.

giandonatoinverso commented 4 months ago

Ok then write to me when it is accepted please

tranmh commented 4 months ago

Change would be: https://github.com/giandonatoinverso/PHP-Dynamic-Qr-code/blob/master/src/lib/Qrcode/Qrcode.php#L83

replace the following line

        $url =
            'https://api.qrserver.com/v1/create-qr-code/?data='.
            $data_to_qrcode.
            '&&size='.$options['size'].'x'.$options['size'].
            '&ecc='.$options['errorCorrectionLevel'].
            '&margin=0&color='.$options['foreground'].
            '&bgcolor='.$options['background'].
            '&qzone=2'.
            '&format='.$data_to_db['format'];

with

        $url =
                'http://localhost:6868/api/qrcode?data='.
                $data_to_qrcode.
                '&size='.$options['size'].
                '&color='.$options['foreground'].
                '&bgcolor='.$options['background'].
                '&ecc='.$options['errorCorrectionLevel'];
giandonatoinverso commented 4 months ago

I saw that the format is missing. Many of my users need all the formats that my script offers. Does this new generation method have them? For example EPS

tranmh commented 4 months ago

https://github.com/skip2/go-qrcode/pull/66 have now the following two formats: png and svg. More will hopefully come.

giandonatoinverso commented 4 months ago

Ok let me know when the other formats will be available