Giter Site home page Giter Site logo

Colab about qrgen HOT 15 CLOSED

aruzeta avatar aruzeta commented on May 29, 2024
Colab

from qrgen.

Comments (15)

aruZeta avatar aruZeta commented on May 29, 2024

I'm sorry I have never used Colab nor I know what it's used for, so I don't know.

from qrgen.

qo4on avatar qo4on commented on May 29, 2024

Unfortunately, I never used Nim.
Probably Colab should work, at least it shows the version of the installed Nim:

!pip install git+https://github.com/demotomohiro/nim4colab.git
%load_ext nim4colab
%%nimc
echo "Nim version is ", NimVersion

Installing Nim stable
done
Hint: used config file '/root/nim-stable/nim/config/nim.cfg' [Conf]
Hint: used config file '/root/nim-stable/nim/config/config.nims' [Conf]
.........................................................
CC: nim-stable/nim/lib/std/private/digitsutils.nim
CC: nim-stable/nim/lib/system/dollars.nim
CC: nim-stable/nim/lib/system/io.nim
CC: nim-stable/nim/lib/system.nim
CC: code.nim
Hint:  [Link]
Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
26647 lines; 1.341s; 31.695MiB peakmem; proj: /root/code.nim; out: /root/code [SuccessX]
Hint: /root/code  [Exec]
Nim version is 1.6.11

But I don't know how to run nimble install, it returns the error undeclared identifier: 'nimble':

%%nimc
nimble install qrgen

Hint: used config file '/root/nim-stable/nim/config/nim.cfg' [Conf]
Hint: used config file '/root/nim-stable/nim/config/config.nims' [Conf]
.........................................................
/root/code.nim(1, 1) Error: undeclared identifier: 'nimble'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (3, 2): 'File' [type declared in /root/nim-stable/nim/lib/system/io.nim(21, 3)]
 (3, 2): 'nimvm' [let declared in /root/nim-stable/nim/lib/system.nim(529, 5)]

from qrgen.

qo4on avatar qo4on commented on May 29, 2024

I managed to run it

%nimble -y install qrgen
%%nimc
import QRgen
let myQR = newQR("https://github.com/aruZeta/QRgen")
myQR.printTerminal

image

from qrgen.

qo4on avatar qo4on commented on May 29, 2024

Just wondering, have you tested the reliability of qr codes with pictures? What parameters should be used to create a qr code so that it works 100% of the time with all phones?

myQR.renderImg("#1d2021","#98971a",100,100,25,img=readImage("QRgen-logo.png"))

from qrgen.

aruZeta avatar aruZeta commented on May 29, 2024

The problem is not the phone but the QR scaner used, depending on the scanner it may or may not read complicated QR codes, like ones with rounded corners, spacing or even images.

Also the image should not be a problem since it calculates it's max size depending on the selected ECC level, so the amount of broken bits can be recovered.

from qrgen.

qo4on avatar qo4on commented on May 29, 2024

For some reason printSvg doesn't work. Is there any way to save the svg to a file?

import QRgen
let myQR = newQR("https://github.com/aruZeta/QRgen")
myQR.printSvg

/root/code.nim(3, 5) Error: expression 'printSvg(myQR, "#ffffff", "#000000", 0, 0, 0, "qrCode", "", "",
         genDefaultCoords(myQR), false)' is of type 'string' and has to be used (or discarded); start of expression here: /root/code.nim(2, 1)

from qrgen.

aruZeta avatar aruZeta commented on May 29, 2024

Yes, printSvg returns you a string, so you just need to pipe it into a file, take a look to the tests file tests/testQRGen.nim, here is an example:

  let qr = newQR("https://github.com/aruZeta/QRgen")
  writeFile(
    "build" / "testingSvg.svg",
    qr.printSvg
  )

from qrgen.

qo4on avatar qo4on commented on May 29, 2024

How do you get this qr code? I would like to remove the dots around the logo as in your example.
image

!wget -O logo.svg https://upload.wikimedia.org/wikipedia/commons/b/b8/YouTube_play_button_icon_%282013%E2%80%932017%29.svg

%%nimc
import QRgen
let qr = newQR("https://github.com/aruZeta/QRgen", ecLevel=qrECH)
writeFile("testingSvg.svg", qr.printSvg("#1d2021", "#98971a", 100, 100, 25, svgImg=readFile("logo.svg")))

testingSvg

from qrgen.

aruZeta avatar aruZeta commented on May 29, 2024

Yes, that's intended behaviour, to avoid it you would just add a non-transparent background to your image, but oh well there should be a way to force a square to be drawn behind it.

from qrgen.

qo4on avatar qo4on commented on May 29, 2024

Do you mean that all the svg need to be specially edited by placing them on an non-transparent background rectangle of the same color as the background of the qr code? Also, the size of this rectangle must be manually adjusted for each qr code so that its borders do not partially overlap the dots of the qr code itself and do not divide them into two parts, right?

from qrgen.

aruZeta avatar aruZeta commented on May 29, 2024

The current implementation does not offer a way to force a background for transparent images.
About the size, you don't need to mind it since it's actually calculated to fit perfectly (and you can even force an x,y position and a width,height, although not recommended since it could mess up the QR code and make it unreadable unless you test it or know what you're doing).

from qrgen.

qo4on avatar qo4on commented on May 29, 2024

Is there any reason why you can't get a qr code like this without editing the svg and placing it on an opaque background?
image

from qrgen.

aruZeta avatar aruZeta commented on May 29, 2024

As I said it's not that there is a reason of why you can't force a layer between the QR and the image, so as in a way to act as the background of the image, but that it's just not implemented.

It shouldn't be a difficult task, but I will try it whenever I have the time and energy to do it.

from qrgen.

qo4on avatar qo4on commented on May 29, 2024

I see, thank you. Anyway, you did a very good job. And it would be absolutely perfect if you manage to add a way to force a background for transparent images.

from qrgen.

aruZeta avatar aruZeta commented on May 29, 2024

Yeah it's something that's missing from the library, but I'm very sorry I don't have any time atm.

from qrgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.